CSS3中translate、transform、translation和animation的区别

1.translate 移动

通过 translate() 方法,元素从其当前位置移动,根据给定的 left(x 坐标) 和 top(y 坐标) 位置参数:

用法:

 transform: translate(50px, 100px);
-ms-transform: translate(50px,100px);
-webkit-transform: translate(50px,100px);
-o-transform: translate(50px,100px);
-moz-transform: translate(50px,100px); 
复制代码

2.transform 改变、变形

旋转:rotate() 顺时针旋转给定的角度,允许负值 rotate(30deg) 扭曲:skew() 元素翻转给定的角度,根据给定的水平线(X 轴) 和垂直线(Y 轴)参数:skew(50deg,20deg) 缩放:scale() 放大或缩小,根据给定的宽度(X 轴)和高度(Y 轴)参数: scale(2,4) 移动:translate() 平移,传进 x,y值,代表沿x轴和y轴平移的距离

综合起来使用:transform: 30deg 1.5 50deg 20deg 100px 200px;

3.transition 过渡

允许CSS属性值在一定的时间区间内平滑的过渡,需要事件的触发,例如单击、获取焦点、失去焦点等

transition:property duration timing-function delay;
复制代码
  • transition-property 规定设置过渡效果的 CSS 属性的名称。
  • transition-duration 规定完成过渡效果需要多少秒或毫秒。
  • transition-timing-function 规定速度效果的速度曲线。
  • transition-delay 定义过渡效果何时开始。
<style>
 div{
    width:100px;
    height:100px;
    background:blue;
    transition:width 2s;
 }
div:hover
 {
    width:300px;
 }
</style>
<div></div>
复制代码

4.animation 动画

语法 animation: name duration timing-function delay iteration-count direction; animation-name 规定需要绑定到选择器的 keyframe 名称. animation-duration 规定完成动画所花费的时间,以秒或毫秒计. animation-timing-function 规定动画的速度曲线. animation-delay 规定在动画开始之前的延迟. animation-iteration-count 规定动画应该播放的次数. animation-direction 规定是否应该轮流反向播放动画.

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
    width:100px;
    height:100px;
    background:red;
    position:relative;
    animation:mymove 5s infinite;
    -webkit-animation:mymove 5s infinite; /*Safari and Chrome*/
}
@keyframes mymove
{
    from {left:0px;}
    to {left:200px;}
}
</style>
</head>
<body>

<div></div>

</body>
</html>
复制代码
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值