CSS3 transition 实战Demo

基础理论

  • transition 有五个属性:
    • property : 属性 , 可以指定哪个CSS属性进行过渡,也能使用all全部属性生效
    • duration : 持续时间
    • timing-function: 过渡函数,有linear(匀速),ease-in(渐现),ease-out(渐隐) ,ease-in-out(渐显渐隐)等。
    • delay : 是延迟 ,就是开始执行前等待的时间

综合写法:transition: <property> <duration> <timing-function> <delay>

直接上例子 , 代码自己新建一个html保存,在主流的浏览器运行即可

LiveDemo

代码块

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>transition Demo</title>
		<style>
		/* transition: <property> <duration> <timing-function> <delay>;*/
			.demobox {
				position: relative;
				left: 25%;
				top:300px;
				border-style: solid;
				border-width: 1px;
				display: block;
				width: 100px;
				height: 100px;
				background-color: #56A892;
				-webkit-transition: all 1s ease-in-out .5s;
				        transition: all 1s ease-in-out .5s;
			}

			.demobox:hover {
				background-color: #fcc;
				width: 200px;
				height: 200px;
				border-radius: 10px;
				background-color: #2AA2E6;
				-webkit-transform: rotate(180deg) skew(-5deg,150deg) scale(.5);
				-ms-transform: rotate(180deg) skew(-5deg,150deg) scale(.5);
				transform: rotate(180deg) skew(-5deg,150deg) scale(.5);
			}

			.btn{
				width:200px;
				height:50px;
				box-shadow: 2px 2px 2px rgba(38,55,64,.9);
				-webkit-transition: all 2s ease-in-out ;
				        transition: all 2s ease-in-out ;
			}

			.btn:hover{
				color:#F5F5F5;
				font-size:bolder;
				background: linear-gradient(-45deg, #36C783, #2A9DC8 );
				box-shadow: 2px 2px 5px #ABABB4 inset;
				-webkit-transform: translateX(250px) translateY(100px) rotate(45deg);
				    -ms-transform: translateX(250px) translateY(100px) rotate(45deg);
				        transform: translateX(250px) translateY(100px) rotate(45deg);
			}
		</style>
	</head>
	<body>
		<p>盒子和按钮的多个属性一起动画.hover触发</p>
		<div class="demobox"></div>

		<button type="button" class="btn">啦啦啦德玛西亚</button>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

crper

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值