欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
    代码实例:
    <!DOCTYPEhtml>
    <html>
    <head>
    <metacharset="UTF-8">
    <title>纯css画一下心</title>
    <style>
    body{
    height:100%;
    margin:0;
    }
    .demo{
    width:1px;
    height:1px;
    margin:300pxauto;
    position:relative;
    animation:tiaodong.8slinearinfinite;
    }
    .demo::before,.demo::after{
    content:'';
    position:absolute;
    width:80px;
    height:120px;
    background-color:red;
    border-radius:50px50px00;
    }
    .demo::after{
    left:28px;
    transform:rotate(45deg);
    }
    .demo::before{
    transform:rotate(-45deg);
    box-shadow:-5px-5px10pxgrey;
    }
    @keyframestiaodong{
    0%{
    transform:scale(1);
    }
    50%{
    transform:scale(1.05);
    }
    100%{
    transform:scale(1);
    }
    }
    </style>
    </head>
    <body>
    <divclass="demo"></div>
    </body>
    </html>
    用的是after和before伪元素实现的,没有考虑兼容性,在IE10之前就显示不出来了。
    可以用span元素替换掉after和before解决掉。
    需要加上:-ms-transform。
    若是用span元素画的话,需要右边的块设置z-index属性。


1.jpg2.jpg




本文转载自中文网


 

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css3-style/c57053.shtml