css3过渡效果

Css3过渡

	什么是css3过渡?CSS3 过渡其实就是元素从一种样式逐渐改变为另一种样式的效果,实现了最初级的动画效果。

过渡作用

	让元素的变化发生平滑的效果,显得不生硬

具体参数的取值及说明

	<transition-property>	定义用于过渡的属性;例:all;

	<transition-duration>	定义过渡过程所需要的时间;(必选,否则不会产生过渡效果);例:2s(两秒);

	<transition-delay>	定义开始过渡的延迟时间;例:1s(一秒);

	<transition-timing-function>	定义过渡的类型;例:ease-in(加速);

Css3过渡综合写法

	例:transition:width,0.5s,1s,linear;
		transition:指定属性,过渡时间,延迟时间,动画类型;
	(注意:transition属性可以同时定义两组或两组以上的过渡效果,最少写一组,也就是过渡时间属性transition-duration;组与组之间用逗号或空格分隔。)

案例:实际效果(附:代码)

初始效果:
在这里插入图片描述
过渡效果:
在这里插入图片描述
代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>
			.box1{
				width:200px;
				height:200px;
				background:red;
				margin:100px;
				border:4px solid #000;
			}
			.box2{
				width:100px;
				height:100px;
				background:pink;
				margin-left:-104px;
				transition:all 1s 0.5s;/*所有属性,过渡时间1s,延迟时间0.5s*/
			}
			.box1:hover .box2{
				margin-left:150px;
				background:gold;
			}
			.box3{
				width:600px;
				height:300px;
				background:skyblue;
				margin:100px;
				border:4px solid #000;
			}
			.box4{
				width:100px;
				height:50px;
				background:red;
				margin:20px 0px;
			}
			.con1{
				transition:all 5s 1s linear;
			}
			.con2{
				transition:all 2s 1s linear;/*匀速*/
			}
			.con3{
				transition:all 2s 1s ease;/*逐步降速,由快到慢*/
			}
			.con4{
				transition:all 2s 1s ease-in;/*逐步加速,由慢到快*/
			}
			.box3:hover .box4{
				width:600px;
				background:yellow;
			}
		</style>
	</head>
	<body>
		<div class="box1">
			<div class="box2"></div>
		</div>
		<div class="box3">
			<div class="box4 con1"></div>
			<div class="box4 con2"></div>
			<div class="box4 con3"></div>
			<div class="box4 con4"></div>
		</div>
	</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值