您的位置:首页 > Web前端 > CSS

:after,:before,css的animation

2018-03-12 15:12 627 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body
{
margin: 0;padding: 0;
}
.div1
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove .5s linear 2s infinite alternate;
-webkit-animation:mymove .5s linear 2s infinite alternate; /*Safari and Chrome*/
}

@keyframes mymove
{
from {top:-20px;}
to {top:20px;}
}

@-webkit-keyframes mymove /*Safari and Chrome*/
{
from {top:-20px;}
to {top:20px;}
}
p
{
transition: all 2s  ease;
position: relative;
}
p:hover{
transform: translate(30px,30px);
}
p:before{content: "开始..";}
p:after{content: "..结束"; /* position: absolute; bottom: 0; right: 0; padding-left: 40px; */}
.div2{
display: block;
min-width:1200px;
min-height: 200px;
background: #ccc;
}
a:after{
content: " (" attr(href) ")"
}
</style>
</head>
<body>
<p><strong>注释:</strong>Internet Explorer 9 以及更早的版本不支持 animation 属性。</p>
<div class="div1"></div>
<div class="div2">Internet Explorer 9 以及更早的版本不支持 animation 属性Internet Explorer 9 以及更早的版本不支持 animation 属性Internet Explorer 9 以及更早的版本不支持 animation 属性Internet Explorer 9 以及更早的版本不支持 animation 属性Internet Explorer 9 以及更早的版本不支持 animation 属性Internet Explorer 9 以及更早的版本不支持 animation 属性</div>
<a href="javascript:void(0);">a:after{content: " (" attr(href) ")"}</a>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: