鼠标经过图片四周加线条

css

<style type="text/css">
			*{
				margin: 0;padding: 0;
			}
			.box{
				overflow: hidden;
				position: relative;
				margin: 120px auto;
				width: 400px;
				height: 255px;
			}
			.box img{
				width: 100%;
			}
			.box hr{
				border: none;
				position: absolute;
			}
			.box .l{
				width: 3px;
				height: 255px;
				background-color: orangered;
				left:0;
				top:-255px;
			}
			.box .t{
				width: 400px;
				height: 3px;
				background-color: orangered;
				left:-400px;
				top:0;
			}
			.box .r{
				width: 3px;
				height: 255px;
				background-color: orangered;
				right: 0;
				bottom:-255px;
			}
			.box .b{
				width: 400px;
				height: 3px;
				background-color: orangered;
				left: 400px;
				bottom: 0;
			}
			.box .shang{
				transform: translateX(400px);
				transition: all .6s;
			}
			.box .zuo{
				transform: translateY(255px);
				transition: all .6s;
			}
			.box .you{
				transform: translateY(-255px);
				transition: all .6s;
			}
			.box .xia{
				transform: translateX(-400px);
				transition: all .6s;
			}
			.box .fu{
				transition: all .6s;
			}
		</style>

html

<div class="box">
			<hr class="l a">
			<hr class="t a">
			<img src="../img/mn.jpeg">
			<hr class="r a">
			<hr class="b a">
		</div>

jquery

$(function(){
				var l = $(".box .l");
				var t = $(".box .t");
				var r = $(".box .r");
				var b = $(".box .b");
				var a = $(".box .a");
				$(".box").hover(
				function(){
					a.removeClass("fu");
					l.addClass("zuo");
					t.addClass("shang");
					r.addClass("you");
					b.addClass("xia");
				},function(){
					l.removeClass("zuo");
					t.removeClass("shang");
					r.removeClass("you");
					b.removeClass("xia");
					a.addClass("fu");
					})
				})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值