利用css简单实现一个跑马灯效果

共享博客

详情 www.sharedblog.cn/?post=67

CSS代码
<style type="text/css">
	div,body,input,textarea,a,select,h1,h2,h3,h4,h5,h6,span,p,ul,ol,li,dl,dd,dt,form,table,span,img{
		margin:0;
		padding:0;
	}
	.box{
		width: 350px;
		height: 150px;
		border: 10px solid rgba(29,6,253,1);
		margin: 30px;
		text-align: center;
		transition: all 3s;
		overflow: hidden;
		position: relative;
	}
	.box a{
		display: block;
		text-decoration: none;
		color: black;
		font-weight: bold;
		font-size: 30px;
		line-height: 150px;
	}
	.box:hover{
		border: 10px solid rgba(29,6,253,0);
	}
	.box .one:nth-child(1){
		width: 350px;
		height: 10px;
		background: pink;
		position: absolute;
		top: 0;
		left: -350px;
	}
	.box .one:nth-child(2){
		width: 350px;
		height: 10px;
		background: pink;
		position: absolute;
		bottom: 0;
		right: -350px;
	}
	.box .one:nth-child(3){
		width: 10px;
		height: 160px;
		background: pink;
		position: absolute;
		bottom: -160px;
		left: 0;
	}
	.box .one:nth-child(4){
		width: 10px;
		height: 160px;
		background: pink;
		position: absolute;
		top: -160px;
		right: 0;
	}
	.box:hover .one:nth-child(1){
		transform: translateX(350px);
		transition: all 2s;
	}
	.box:hover .one:nth-child(2){
		transform: translateX(-350px);
		transition: all 2s;
	}
	.box:hover .one:nth-child(3){
		transform: translateY(-160px);
		transition: all 3s;
	}
	.box:hover .one:nth-child(4){
		transform: translateY(160px);
		transition: all 3s;
	}
</style>
HTML代码
<body>
	<div class="box">
		<div class="one"></div>
		<div class="one"></div>
		<div class="one"></div>
		<div class="one"></div>
		<a href="#">鹏仔先生</a>
	</div>
</body>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值