css3中一些常用的动画效果

1.动画效果一:鼠标放上去,后面的背景图放大到一定程度,下面的有个内容盒子,以一定的速度从下向上运动,并且盒子的背景颜色逐渐加深。

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		* {
			margin: 0;
			padding: 0;
		}
		.big {
			width: 420px;
			height: 372px;
			overflow: hidden;
			position: relative;
			border: 1px solid #000;
		}
		.bigone {
			position: absolute;
			top: 0;
			left: 0;
		}
		.bigone .pic {
			width: 100%;
			height: 100%;
			overflow: hidden;
		}
		.bigone .pic img {
			width: 100%;
			height: 100%;
			transition: all 0.5s;
		}
		.big:hover img {
			transform: scale(1.5);
		}
		.bigone .dl {
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 109px;
			background: rgba(0,0,0,0.4);
		}
		.bigone .dl p {
			font-size: 30px;
			color: #fff;
			padding: 20px;
		}
		.bigtwo {
			width: 100%;
			height: 260px;
			position: absolute;
			bottom: -120px;
			left: 0;
			background: rgba(0,0,255,0);
			transition: all 0.5s;
		}
		.bigtwo p {
			font-size: 18px;
			color: rgba(255,255,255,0);
			padding: 10px;
		}
		.big:hover .bigtwo {
			transform: translateY(-120px);
			background: rgba(0,0,255,0.7);
		}
		.big:hover p {
			color: rgba(255,255,255,1);
		}
	</style>
</head>
<body>
	<div class="big">
		<div class="bigone">
			<div class="pic">
				<img src="1.jpg" alt="">
			</div>
			<div class="dl">
				<p>这是一段话</p>
			</div>
		</div>
		<div class="bigtwo">
			<p>这是遮罩层</p>
		</div>
	</div>
</body>
</html>

效果二:鼠标放到盒子上有一个类似于开门的效果,并且下面的背景颜色和字体的颜色会有一个渐变的过程。

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		.big {
			width: 500px;
			height: 400px;
			position: relative;
			overflow: hidden;
		}
		.big:after,.big:before {
			content: "";
			display: block;
			width: 50%;
			height: 100%;
			background: rgba(0,0,0,0.4);
			position: absolute;
			top: 0;
			transition: all 1s;
		}
		.big:after {
			left: 0;
		}
		.big:before {
			right: 0;
		}
		a {
			position: absolute;
			top: 50%;
			left: 50%;
			margin-left: -100px;
			margin-top: -100px;
			width: 200px;
			height: 200px;
			border-radius: 50%;
			background: rgba(0,0,0,0.7);
			color: #fff;
			text-decoration: none;
			transition: all 1s;
		}
		.small {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%,-50%);
		}
		span {
			font-size: 16px;
			color: #fff;
			transition: all 1s;
		}
		p {
			font-size: 12px;
			color: #fff;
			text-align: center;
			transition: all 1s;
		}
		.big:hover:after {
			left: -50%;
		}
		.big:hover:before {
			right: -50%;
		}
		.big:hover a {
			background: yellow;
		}
		.big:hover span,.big:hover p {
			color: red;
		}
	</style>
</head>
<body>
	<div class="big">
		<a href="#">
			<div class="small">
				<span>这是一个盒子</span>
				<p>摄影</p>
			</div>
		</a>
	</div>
</body>
</html>


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值