jquery實(shí)現(xiàn)邊框特效
本文實(shí)例為大家分享了jquery實(shí)現(xiàn)邊框特效的具體代碼,供大家參考,具體內(nèi)容如下
主要思想
1.將四個(gè)div分別定位到大div的上下左右位置
2.分別設(shè)置成寬度為0或者高度為0
3.讓其執(zhí)行給定動(dòng)畫(huà),即多少毫秒讓寬度或者高度變?yōu)橹付ǖ拈L(zhǎng)度
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實(shí)現(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) });
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
jquery 注意事項(xiàng)與常用語(yǔ)法小結(jié)
jquery 注意事項(xiàng)與常用語(yǔ)法小結(jié),學(xué)習(xí)jquery的朋友最好收藏下。2010-06-06javaScript和jQuery自動(dòng)加載簡(jiǎn)單代碼實(shí)現(xiàn)方法
給大家介紹一下利用javaScript和jQuery實(shí)現(xiàn)自動(dòng)加載最簡(jiǎn)單的代碼寫(xiě)法。2017-11-11jQuery EasyUI 布局之動(dòng)態(tài)添加tabs標(biāo)簽頁(yè)
本文給大家介紹jquery easyui布局之動(dòng)態(tài)添加tabs標(biāo)簽頁(yè),實(shí)現(xiàn)思路是這樣的通過(guò)調(diào)用add方法就可以輕松實(shí)現(xiàn),本文分步驟給大家詳細(xì)介紹,需要的朋友一起學(xué)習(xí)吧2015-11-11jquery使用echarts實(shí)現(xiàn)有向圖可視化功能示例
這篇文章主要介紹了jquery使用echarts實(shí)現(xiàn)有向圖可視化功能,結(jié)合完整實(shí)例形式分析了jquery的echarts.js插件實(shí)現(xiàn)有向圖可視化相關(guān)實(shí)現(xiàn)技巧與操作注意事項(xiàng),需要的朋友可以參考下2019-11-11jQuery滾動(dòng)監(jiān)聽(tīng)實(shí)現(xiàn)商城樓梯式導(dǎo)航效果
這篇文章主要介紹了jQuery滾動(dòng)監(jiān)聽(tīng),實(shí)現(xiàn)商城樓梯式導(dǎo)航,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03jQuery模擬實(shí)現(xiàn)的select點(diǎn)擊選擇效果【附demo源碼下載】
這篇文章主要介紹了jQuery模擬實(shí)現(xiàn)的select點(diǎn)擊選擇效果,涉及jQuery響應(yīng)鼠標(biāo)點(diǎn)擊動(dòng)態(tài)修改頁(yè)面元素樣式的相關(guān)操作技巧,并附帶demo源碼供讀者下載,需要的朋友可以參考下2016-11-11