CSS按钮动画

  1. btn-default:基本样式按钮

  2. btn-primay:蓝色按钮

  3. btn-success:绿色按钮

  4. btn-error:红色按钮

  5. btn-warning:黄色按钮

  6. btn-anim1:按钮爆炸动画效果

  7. btn-anim2:按钮左到右动画效果

  8. btn-anim3:按钮左上角爆炸动画效果

  9. btn-anim4:按钮下到上动画效果

 

html,
body {
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
}

/* 爆炸:中心爆炸,角落爆炸 */
@keyframes anim1 {
	from {
		width: 1px;
		height: 1px;
		opacity: 1;
		transform: scale(0);
		background-color: #FFFFFF;
	}

	to {
		width: 1px;
		height: 1px;
		opacity: 0;
		transform: scale(100);
		background-color: #FFFFFF;
	}
}

/* 左边到右边 */
@keyframes atob2 {
	from {
		width: 1px;
		opacity: 1;
		transform: scale(0);
		background-color: #FFFFFF;
	}

	to {
		width: 1px;
		opacity: 0;
		transform: scale(100);
		background-color: #FFFFFF;
	}
}

/* 下边到上边*/
@keyframes atob4 {
	from {
		height: 1px;
		opacity: 1;
		transform: scale(0);
		background-color: #FFFFFF;
	}

	to {
		height: 1px;
		opacity: 0;
		transform: scale(100);
		background-color: #FFFFFF;
	}
}

.clearfix::after {
	content: '';
	display: flex;
	clear: both;
}

.warp {
	position: relative;
	width: 100%;
	height: 100%;
	background-color: #23B8FF;
}

.warp .btns {
	position: absolute;
	left: 50%;
	top: 200px;
	display: flex;
	flex-direction: row;
	justify-content: space-evenly;
	width: 500px;
	margin-left: -250px;
}

/* 
公共样式 不依赖其他 
*/
.btn-default {
	position: relative;
	display: inline-block;
	padding: 6px 12px;
	margin-bottom: 0;
	font-size: 12px;
	font-weight: 400;
	line-height: 1.42857143;
	text-align: center;
	white-space: nowrap;
	vertical-align: middle;
	-ms-touch-action: manipulation;
	touch-action: manipulation;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	background-image: none;
	border: 1px solid transparent;
	border-radius: 4px;
	color: #FFF;
	overflow: hidden;
}

.btn-default.btn-primay {
	background-color: #337ab7;
}

.btn-default.btn-success {
	background-color: #5cb85c;
}

.btn-default.btn-error {
	background-color: #d9534f;
}

.btn-default.btn-warning {
	background-color: #f0ad4e;
}

/* 中心爆炸 */
.btn-default.btn-anim1:hover::before {
	content: "";
	display: inline-block;
	position: absolute;
	left: 49%;
	top: 49%;
	border-radius: 50%;
	animation: anim1 .5s linear forwards;
}

/* 左边到右边 或者右边到左边 */
.btn-default.btn-anim2:hover::before {
	content: "";
	display: inline-block;
	position: absolute;
	left: 0;
	top: 49%;
	height: 100px;
	animation: atob2 .5s linear forwards;
}

/* 左上角到右下角 */
.btn-default.btn-anim3:hover::before {
	content: "";
	display: inline-block;
	position: absolute;
	left: 0;
	top: 0;
	border-radius: 50%;
	animation: anim1 .5s linear forwards;
}

/* 下边到上边 */
.btn-default.btn-anim4:hover::before {
	content: "";
	display: inline-block;
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100px;
	border-radius: 50%;
	animation: atob4 .5s linear forwards;
}
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="./css/index.css"/>
	</head>
	<body>
		<div class="warp">
			<div class="btns">
				<div class="btn-default btn-primay btn-anim1">主要</div>
				<div class="btn-default btn-error btn-anim2">错误</div>
				<div class="btn-default btn-success btn-anim3">成功</div>
				<div class="btn-default btn-warning btn-anim4">警告</div>
				<span class="btn-default btn-primay btn-anim4">我是button</span>
				<button class="btn-default btn-error btn-anim1">我是button</button>
			</div>
		</div>
	</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值