博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
css3部分知识点
阅读量:5171 次
发布时间:2019-06-13

本文共 4014 字,大约阅读时间需要 13 分钟。

 

1.选择器

  id class  标签  子代  后代  交集  并集   通配符选择器  伪类选择器  结构选择器  属性选择器  相邻+选择器  兄弟选择器~

2.浏览器内核

  谷歌的内核是webkit

  火狐的内核是gecko

  IE的内核是trident

  欧朋的内核是presto

  国内浏览器的内核 webkit

3.css3针对同一样式在不同浏览器的兼容 需要在样式属性前加上内核前缀。

谷歌  -webkit-transition:

欧朋 OPera -o-transition

飞狐 firefox   -moz-transition

IE   -ms-transition

4.c3中的过滤属性transition

transition 简写属性,用于在一个属性中设置四个过度属性

transition-propert     规定应用过度的css属性的名称。

transition-duration     定义过渡效果花费的时间。 默认是0.

transition-timing--function  规定过渡效果的时间曲线。默认是“”ease“”

transition-delay                 规定过渡效果何时开始。默认是0.

div[name-zhang]{

width:100px;

height:30px;

background:red;

transition:width 2s linear 1s;

}

注意:时间一定要带单位

  eg:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            #a {
                width: 100px;
                height: 50px;
                background: orange;
                /*分开写*/
                transition-property: width;
                transition-duration: 2s;
                transition-timing-function: linear;
                transition-delay: 1s;
                /*简写*/
                transition: width 2s linear; 1s
            }
            #a:hover {
                width: 500px;
            }
        </style>
    </head>
    <body>
        <div id="a"></div>
    </body>
<ml>
5.css3的动画(animation):
  eg:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            div {
                width: 100px;
                height: 100px;
                background: orange;
                position: absolute;
                left: 0;
                top: 0;
                animation: reverse;/*反向*/
                animation: donghua 4000ms linear infinite;
                animation-direction: alternate;
            }
            div:hover {
                animation-play-state: paused;
            }
            @-webkit-keyframes donghua{
                25%{
                    top: 0px;
                    left: 300px;
                }
                50%{
                    top: 300px;
                    left: 300px;
                }
                75%{
                    top: 300px;
                    left: 0px;
                }
                100%{
                    top: 0px;
                    left: 0px;
                }
            }
        </style>
    </head>
    <body>
        <div></div>
    </body>
<ml>
 
6.2D效果:
  css3中的2D特效是方法(函数),提供了四个方法
  translate():平移,有两个参数
  rotate():旋转,参数2是数字,1代表不变
  scale():缩放,只充当属性值
  eg:
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            div {
                width: 100px;
                height: 100px;
                background: orange;
                position: absolute;
                top: 300px;
                left: 50%;
                transform: rotateZ(0deg);
                transform-origin: left top;
                transform: translate(10px,10px);
                transform: scale(2);
                animation: name 2s linear infinite;
            }
            @-webkit-keyframes name{
                from{
                    transform: rotateZ(0deg);
                }
                to{
                    transform: rotateZ(360deg);
                }
        </style>
    </head>
    <body>
        <div></div>
    </body>
<ml>
6.3D效果:
  原理:近大远小,perspection
  如果元素要有3D的效果,perspection给他的父级元素
  transform-style:preserve-3d的内部子元素成3D效果
  eg:盒子效果
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            body {
                -webkit-perspective: 3000px;
            }
            .box {
                width: 400px;
                height: 400px;
                /*border: 1px solid green;*/
                position: absolute;
                left: 50%;
                top: 50%;
                margin: -200px 0 0 -200px;
                transform-style: preserve-3d;
                margin-top: 200px;
                animation: name 4s linear infinite;
            }
            @-webkit-keyframes name{
                from{transform: rotateX(0) rotateX(0);}
                to{transform: rotate(360deg) rotateX(360deg);}
            }
            .box>div {
                width: 400px;
                height: 400px;
                position: absolute;
                top: 0;
                left: 0;
                text-align: center;
                line-height: 400px;
                font-size: 30px;
                color: wheat;
                transition: all 2s linear;
            }
            .box>div:nth-of-type(1) {
                background: blue;
                transform: translateZ(-200px);
            }
            .box>div:nth-of-type(2) {
                background: blueviolet;
                transform: rotateX(90deg) translateZ(200px);
            }
            .box>div:nth-of-type(3) {
                background: goldenrod;
                transform: rotateX(90deg) translateZ(-200px);
            }
            .box>div:nth-of-type(4) {
                background: green;
                transform: rotateY(90deg) translateZ(200px);
            }
            .box>div:nth-of-type(5) {
                background: gray;
                transform: rotateY(90deg) translateZ(-200px);
            }
            .box>div:nth-of-type(6) {
                background: skyblue;
                transform: translateZ(200px);
            }
            .box:hover div:nth-of-type(1) {
                transform: translateZ(-400px);
            }
            .box:hover div:nth-of-type(2) {
                transform: rotateX(90deg) translateZ(400px);
            }
            .box:hover div:nth-of-type(3) {
                transform: rotateX(90deg) translateZ(-400px);
            }
            .box:hover div:nth-of-type(4) {
                transform: rotateY(90deg) translateZ(400px);
            }
            .box:hover div:nth-of-type(5) {
                transform: rotateY(90deg) translateZ(-400px);
            }
            .box:hover div:nth-of-type(6) {
                transform: translateZ(400px);
            }
        </style>
    </head>
    <body>
        <div class="box">
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
        </div>
    </body>
<ml>

 

转载于:https://www.cnblogs.com/txf-123/p/10554508.html

你可能感兴趣的文章
poi 和jxl导出excel(2)
查看>>
javascript时间戳转换成yyyy-MM-DD格式
查看>>
2059 mysql
查看>>
service XXX does not support chkconfig
查看>>
RXJAVA之Subject
查看>>
TC2.0图形函数详解
查看>>
Interview Preparation III
查看>>
数据结构学习---有序链表的合并
查看>>
js 的基础知识变量
查看>>
使用X-shell管理员root连接ubuntu17.10服务器拒绝密码的一个失误!
查看>>
js中eval详解
查看>>
使用IronPython集成Python和.NET
查看>>
扩展ScriptBundle,支持混淆加密javascript
查看>>
WCF自寄宿
查看>>
数据库系统异常排查之思路
查看>>
FastReport使用一——简介
查看>>
ODbgscript 1.82.x Document
查看>>
C++ malloc new 的区别
查看>>
js放大镜的案例
查看>>
jquery的jsonp
查看>>