jQuery實(shí)現(xiàn)流動虛線框的方法
本文實(shí)例講述了jQuery實(shí)現(xiàn)流動虛線框的方法。分享給大家供大家參考。具體分析如下:
在百度UEditor的首頁看到一個流動的虛線框的效果,所以自己用jQuery嘗試也寫一個,效果如下:
css:
.dashed-box{width:500px;height:100px;overflow:hidden;position:relative;} .dashed-top{width:2000px;height:0px;border-bottom:2px #ccc dashed;position:absolute;top:0;left:-1400px;} .dashed-left{width:0px;height:2000px;border-left:2px #ccc dashed;position:absolute;left:0;top:-1600px;} .dashed-bottom{width:2000px;height:0px;border-bottom:2px #ccc dashed;position:absolute;left:0px;bottom:0;} .dashed-right{width:0px;height:2000px;border-left:2px #ccc dashed;position:absolute;right:0;top:-1600px;}
HTML:
<div class="dashed-box"> <div class="dashed-top"></div> <div class="dashed-left"></div> <div class="dashed-right"></div> <div class="dashed-bottom"></div> </div>
jQuery:
setInterval(function(){ var $left=$(".dashed-top").css("left"); var $top=$(".dashed-bottom").css("left"); $left=parseInt($left); $top=parseInt($top); if($left<0){ $left+=2; }else{ $left=-1400; } if($top>-1000){ $top-=2; }else{ $top=0; } $(".dashed-top").css("left",$left+"px"); $(".dashed-right").css("top",$left+"px"); $(".dashed-bottom").css("left",$top+"px"); $(".dashed-left").css("top",$top+"px"); },60);
希望本文所述對大家的jQuery程序設(shè)計有所幫助。
- jquery調(diào)取json數(shù)據(jù)實(shí)現(xiàn)省市級聯(lián)的方法
- Jquery 實(shí)現(xiàn)checkbox全選方法
- jQuery+ajax實(shí)現(xiàn)動態(tài)執(zhí)行腳本的方法
- 使用jQuery實(shí)現(xiàn)input數(shù)值增量和減量的方法
- jquery實(shí)現(xiàn)搜索框常見效果的方法
- jQuery實(shí)現(xiàn)tag便簽去重效果的方法
- jquery搜索框效果實(shí)現(xiàn)方法
- jQuery老黃歷完整實(shí)現(xiàn)方法
- jquery果凍抖動效果實(shí)現(xiàn)方法
- jquery隔行換色效果實(shí)現(xiàn)方法
相關(guān)文章
jquery.Callbacks的實(shí)現(xiàn)詳解
這篇文章主要給大家介紹的是jQuery.Callback()的實(shí)現(xiàn),這個函數(shù)常見的應(yīng)用場景是事件觸發(fā)機(jī)制,也就是設(shè)計模式中的觀察者(發(fā)布、訂閱機(jī)制),目前Callbacks對象用于queue、ajax、Deferred對象中,下面通過這篇文章來詳細(xì)看看關(guān)于jquery.Callbacks實(shí)現(xiàn)的介紹吧。2016-11-11jquery中g(shù)et和post的簡單實(shí)例
本篇文章主要是對jquery中g(shù)et和post的簡單實(shí)例進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-02-02一句jQuery代碼實(shí)現(xiàn)返回頂部效果(簡單實(shí)用)
本文主要分享了利用一句jQuery代碼實(shí)現(xiàn)返回頂部效果的實(shí)例。代碼簡單,保存到HTML文件就可以體驗效果。下面跟著小編一起來看下吧2016-12-12詳細(xì)介紹jQuery.outerWidth() 函數(shù)具體用法
這篇文章通過jQuery示例代碼演示outerWidth()函數(shù)的具體用法,介紹的非常詳細(xì),有需要的朋友可以借鑒2015-07-07用jQuery實(shí)現(xiàn)優(yōu)酷首頁輪播圖
本文主要介紹了用jQuery實(shí)現(xiàn)優(yōu)酷首頁輪播圖的思路與方法。具有一定的參考價值,下面跟著小編一起來看下吧2017-01-01Jquery 設(shè)置標(biāo)題的自動翻轉(zhuǎn)
我們平時在開發(fā)web程序的時候,想把一個新聞源滾動顯示新聞的條目的標(biāo)題及內(nèi)容摘要,而且是每次一條,有點(diǎn)類似csdn的滾動廣告。2009-10-10JQuery中html()方法使用不當(dāng)帶來的陷阱
html方法當(dāng)不傳參數(shù)時用來獲取元素的html內(nèi)容2011-04-04