JQ鼠标悬停边框围绕动态显示效果

<!doctype html> <html> <head> <meta charset="utf-8"> <title>鼠标悬停边框围绕效果</title> <script src="http://libs.baidu.com/jquery/1.8.3/jque...
<!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="" style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;">
    <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="" style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;">
    <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>

attachments-2020-06-C6vtvOUJ5ef6c62998569.png

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章