web前端学习11-css动画实例
<html>
<head>
<meta charset="utf-8">
<title>HTML动画过渡实例</title>
<style type="text/css">
.div{
text-align: center;
}
.image{
margin-top: 20px;
width: 20%;
height: 20%;
}
html:hover .image{/* 鼠标就如网页界面就会改变image */
animation-name: img;/* 动画名称 */
animation-delay: 100ms;/* 延迟时长 */
animation-duration: 5s;/* 动画时长 */
animation-fill-mode: forwards;/* 设置这个forwards,
当鼠标不移出区域就会使动画停留在to阶段 */
}
@keyframes img{
from{}
to{
margin-top: 0px;
margin-bottom: 0px;
padding:0px;
width: 50%;
height: 50%;
}
}
.hero{
font-family: "arial, helvetica, sans-serif";
font-size: 40px;
text-shadow: 1px 1px 5px red ;/* 水平偏移1px,垂直偏移1px,模糊程度2px,色值 */
margin-top: 0px;
opacity: 0;
}
html:hover .hero{
transition-delay: 0.5s;/* 动画时长 */
transition-duration: 0s;/* 延迟时间 */
font-family: "arial, helvetica, sans-serif";
font-size: 40px;
text-shadow: 1px 1px 5px blue ;
margin-top: 0px;
opacity: 0.9;
}
html:
</style>
</head>
<body>
<div class="div">
<img class="image" src="image/weizh.jpg"/>
<p class="hero">英雄皮肤</p>
<img class="image2" src="image/u=1340842496,1488220004&fm=26&gp=0.jpg"/>
</div>
</body>
</html>
文章仅供参考