html时间函数自动变色,CSS3 transition过渡效果(变形、变色、旋转、停顿时间)...

87cfcfa934f625c037774c4bf3b12c9e.gif

三个案例,分别用transition实现了变色 变形 旋转以及停顿时间。

直接分享代码:html>

菜鸟教程(runoob.com)

.demo1 {

width: 100px;height: 100px;background: red;

-webkit-transition: width 2s, height 2s,background 2s;

-webkit-transform 2s; /* 旋转时间 For Safari 3.1 to 6.0 */

transition: width 2s, height 2s, transform 2s, background 2s;}

.demo1:hover {width: 300px;height: 200px;background: blue;

-webkit-transform: rotate(180deg); /* 旋转角度 Chrome, Safari, Opera */

transform: rotate(180deg);/* 旋转角度*/}

/*------------------------------------------------------*/

.demo2{width:100px;height:100px;

background:red;

color: #FFF;

transition:width 2s,height 2s,background 2s;

-webkit-transition:width 2s,height 2s,background 2s; /* Safari */}

.demo2:hover{width:300px;background:blue;}

/*-----------------------------------------------------------*/

.demo3{width:100px;height:100px;background:red;

transition-property:width;

transition-duration:1s;

transition-delay:1.2s;

/* Safari */

-webkit-transition-property:width;

-webkit-transition-duration:1s;

-webkit-transition-delay:1.2s;}

.demo3:hover{width:500px;}

/* --------------------------------------------------*/

注意:该实例无法在 Internet Explorer 9 及更早 IE 版本上工作。

拉长拉宽、变色、旋转
拉长、变色
停顿时间、拉长、变色

对于transition一定要多多学习和熟悉使用,很多情况下可以省去写JS的烦恼。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值