css transition兼容性,CSS3 过渡(Transition)

过渡 transition

复合属性,使CSS属性值在不使用 Flash 动画或 JavaScript 的情况下,当元素从一种样式变换为另一种样式时为元素添加效果

取值:

:检测或设置对象中参与过渡的属性

:检测或设置对象过渡的持续时间

:检测或设置对象中过渡的动画类型

:检测或设置对象延迟过渡的时间

1、过渡属性

取值:none | all | property

例如:transition-property: width;

transition-property: border-color, background-color, color;

2、过渡时间 

取值:以 s | ms 作为单位

3、过渡时间曲线函数  

取值:预定的值或贝塞尔曲线

ease:默认值,慢速开始,快速变快,再慢速结束

linear:匀速

ease-in:慢速开始,加速效果

ease-out:快速开始,减速效果

ease-in-out:慢速开始和结束,中间先加后减

4、过渡延迟 

取值:以 s | ms 作为单位

语法:transition: property duration timing-function delay;

例如:

transition: transform 2s, border-radius 2s

transition: all .5s ease-in .1s;

激发过渡效果:现阶段,只能通过 鼠标移入 时进行激发

兼容性:

d5acd122a348376216f5c89333c86de5.png

代码示例一:html>

Document

#d1{

width:200px;

height:200px;

background-color:#369;

text-align:center;

line-height:200px;

font-size:18px;

/*1、过渡属性*/

transition-property:all;

/*2、过渡时间*/

transition-duration:2s;

/*3、速度曲线函数*/

transition-timing-function:linear;

/*4、延迟*/

transition-delay:0s;

}

#d1:hover{

/*通过转换-位移实现 位置向右移动 200px*/

transform:translate(500px) rotate(360deg);

border-radius:50%;

background-color:#693;

}

滚动的元素

滚动前:

6b1ccb96bdf51051f305abe1b55d0243.png

滚动中:

cd9fac0c87e088dabc9bddc1d5d121b1.png350e8dbc0b294b44da1d77e0608b3fc6.png

代码示例二:html>

Document

h1{font-size:16px;}

.test{overflow:hidden;width:100%;margin:0;padding:0;list-style:none;}

.test li{float:left;width:100px;height:100px;margin:0 5px;border:1px solid #ddd;background-color:#eee;text-align:center;

-webkit-transition:background-color 3.5s ease-in;

-moz-transition:background-color 3.5s ease-in;

transition:background-color 3.5s ease-in;

}

.test li:nth-child(1):hover{background-color:#bbb;}

.test li:nth-child(2):hover{background-color:#999;}

.test li:nth-child(3):hover{background-color:#630;}

.test li:nth-child(4):hover{background-color:#090;}

.test li:nth-child(5):hover{background-color:#f00;}

请将鼠标移动到下面的矩形上:

  • 背景色过渡
  • 背景色过渡
  • 背景色过渡
  • 背景色过渡
  • 背景色过渡

87768ce61f8a3099bf17cf078fec7720.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值