鼠标悬停边框围绕效果--动态边框

<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>鼠标悬停边框围绕效果</title>
		<script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
		<style>
			* {
				margin: 0;
				padding: 0;
				list-style: none;
			}

			img {
				border: 0;
				width: 300px;
				height: 150px;
			}

			.box {
				width: 300px;
				height: 150px;
				margin: 20px auto;
				position: relative;
				border: 1px solid #eee;
			}

			.box .border-left {
				width: 1px;
				height: 0px;
				background: black;
				position: absolute;
				left: -1px;
				bottom: 0;
			}

			.box .border-bottom {
				width: 0px;
				height: 1px;
				background: black;
				position: absolute;
				left: 0;
				bottom: 0px;
			}

			.box .border-top {
				width: 0px;
				height: 1px;
				background: black;
				position: absolute;
				right: 0;
				top: 0px;
			}

			.box .border-right {
				width: 1px;
				height: 0px;
				background: black;
				position: absolute;
				right: -1px;
				top: 0;
			}
		</style>
	</head>
	<body>
		<div class="box">
			    <img src="http://dev.ixincheng.com/xcview/images/xianxia_03.jpg">
			    <div class="border-left"></div>
			    <div class="border-bottom"></div>
			    <div class="border-top"></div>
			    <div class="border-right"></div>
		</div>
		<div class="box">
			    <img src="http://dev.ixincheng.com/xcview/images/xianxia_03.jpg">
			    <div class="border-left"></div>
			    <div class="border-bottom"></div>
			    <div class="border-top"></div>
			    <div class="border-right"></div>
		</div>


		<script>
			$(function() {
				var lanren_width = $('.box').width();
				var lanren_height = $('.box').height();
				$('.box').each(function() {
					$(this).hover(function() {
						$(this).find('.border-left,.border-right').stop().animate({
							height: lanren_height + 'px'
						}, 400);
						$(this).find('.border-top,.border-bottom').stop().animate({
							width: lanren_width + 'px'
						}, 400);
					}, function() {
						$(this).find('.border-left,.border-right').stop().animate({
							height: '0'
						}, 400);
						$(this).find('.border-top,.border-bottom').stop().animate({
							width: '0'
						}, 400);
					});
				});
			});
		</script>

	</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

知 秋~

文章里可以看到打赏码哦~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值