jquery實現(xiàn)邊框特效
本文實例為大家分享了jquery實現(xiàn)邊框特效的具體代碼,供大家參考,具體內容如下
主要思想
1.將四個div分別定位到大div的上下左右位置
2.分別設置成寬度為0或者高度為0
3.讓其執(zhí)行給定動畫,即多少毫秒讓寬度或者高度變?yōu)橹付ǖ拈L度
html代碼
<div class="box"> ? ? <div class="border_top"></div> ? ? <div class="border_bottom"></div> ? ? <div class="border_left"></div> ? ? <div class="border_right"></div> </div>
css代碼
.box{
? ? ? ? width:234px;
? ? ? ? height:300px;
? ? ? ? position:relative;
}
.border_bottom,.border_left,.border_right,.border_top{
? ? background: #ff6700;
? ? position: absolute;
? ? font-size: 0px;
? ? transition: all 0.5s ease-out;
? ? z-index: 99;
}
.border_bottom,.border_top{
? ? height: 1px;
? ? width: 0px;
}
.border_right,.border_left{
? ? height: 0px;
? ? width: 1px;
}
.border_top {
? ? top:0px;
? ? left:0px;
}
.border_right {
? ? top:0px;
? ? right:0px;
}
.border_bottom {
? ? right: 0px;
? ? bottom: 0px;
}
.border_left {
? ? left: 0px;
? ? bottom: 0px;
}js實現(xiàn)效果
1.引入jquery文件
<script src="jquery-1.8.3.min.js"></script>
2.jquery代碼
$('.main>li').hover(function(){
? ? var index=$(this).index();
? ? $(".border_top").stop(true,true);
? ? $(".border_left").stop(true,true);
? ? $(".border_bottom").stop(true,true);
? ? $(".border_right").stop(true,true);
? ? $(".border_top").eq(index).animate({width:"234px"},100)
? ? $(".border_left").eq(index).animate({height:"300px"},100)
? ? $(".border_bottom").eq(index).animate({width:"234px"},100)
? ? $(".border_right").eq(index).animate({height:"300px"},100)
},function(){
? ? var index=$(this).index();
? ? $(".border_top").stop(true,true);
? ? $(".border_left").stop(true,true);
? ? $(".border_bottom").stop(true,true);
? ? $(".border_right").stop(true,true);
? ? $(".border_top").eq(index).animate({width:"0"},100)
? ? $(".border_left").eq(index).animate({height:"0"},100)
? ? $(".border_bottom").eq(index).animate({width:"0"},100)
? ? $(".border_right").eq(index).animate({height:"0"},100)
});以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
jquery插件hiAlert實現(xiàn)網(wǎng)頁對話框美化
hiAlert是一款基于jQuery的信息提示插件,它支持操作成功、操作失敗和操作提醒三種信息提示方式。hiAlert瀏覽器兼容性非常好,支持更改提示內容,支持定位提示框的位置,可配置插件參數(shù)。2015-05-05
jQuery AJAX實現(xiàn)調用頁面后臺方法和web服務定義的方法分享
jQuery AJAX實現(xiàn)調用頁面后臺方法和web服務定義的方法分享,需要的朋友可以參考下2012-03-03
jQuery EasyUI基礎教程之EasyUI常用組件(推薦)
這篇文章主要介紹了jQuery EasyUI基礎教程之EasyUI常用組件(推薦),非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-07-07
從零開始學習jQuery (六) jquery中的AJAX使用
本篇文章講解如何使用jQuery方便快捷的實現(xiàn)Ajax功能.統(tǒng)一所有開發(fā)人員使用Ajax的方式.2011-02-02
jQuery+ajax實現(xiàn)動態(tài)添加表格tr td功能示例
這篇文章主要介紹了jQuery+ajax實現(xiàn)動態(tài)添加表格tr td功能,結合實例形式分析了jQuery基于ajax動態(tài)創(chuàng)建頁面table元素相關操作技巧,需要的朋友可以參考下2018-04-04
jQuery實現(xiàn)鼠標移到某個對象時彈出顯示層功能
這篇文章主要介紹了jQuery實現(xiàn)鼠標移到某個對象時彈出顯示層功能,涉及jQuery基于事件響應動態(tài)操作頁面元素屬性相關實現(xiàn)技巧,需要的朋友可以參考下2018-08-08

