CSS 1.css介绍 css指的是层叠样式表(cascading style sheets) 官方文档:https://www.w3school.com.cn/css/index.asp为什么需要c
顺晟科技
2021-09-23 10:31:56
182
CSS实现动画的方式(2种)
种:transition + transform
transition:设置样式的属性值是如何从一种状态过渡到另一种状态的
transform:主要应用于元素的2D或者3D转换,可以用来设置元素的形状改变。例如rotate(旋转),scale(缩放),skew(扭曲),translate(平移)
div:hover {
transition: 2s;
transform: translateX(100px);
}
第二种:animation + keyfaram
<!DOCTYPE html>
<html>
<head>
<style>
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:myfirst 5s;
-moz-animation:myfirst 5s; /* Firefox */
-webkit-animation:myfirst 5s; /* Safari and Chrome */
-o-animation:myfirst 5s; /* Opera */
}
@keyframes myfirst
{
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:200px; top:0px;}
50% {background:blue; left:200px; top:200px;}
75% {background:green; left:0px; top:200px;}
{background:red; left:0px; top:0px;}
}
@-moz-keyframes myfirst /* Firefox */
{/* 内容同上 */}
@-webkit-keyframes myfirst /* Safari and Chrome */
{/* 内容同上 */}
@-o-keyframes myfirst /* Opera */
{/* 内容同上 */}
</style>
</head>
<body>
<div></div>
</body>
</html>
09
2022-11
09
2022-11
09
2022-11
09
2022-11
09
2022-11
19
2022-10