jQuery實現(xiàn)流動虛線框的方法
更新時間:2015年01月29日 14:49:31 作者:穗溪
這篇文章主要介紹了jQuery實現(xiàn)流動虛線框的方法,可實現(xiàn)百度UEditor首頁流動虛線框的效果,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了jQuery實現(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è)計有所幫助。
相關(guān)文章
一句jQuery代碼實現(xiàn)返回頂部效果(簡單實用)
本文主要分享了利用一句jQuery代碼實現(xiàn)返回頂部效果的實例。代碼簡單,保存到HTML文件就可以體驗效果。下面跟著小編一起來看下吧2016-12-12詳細(xì)介紹jQuery.outerWidth() 函數(shù)具體用法
這篇文章通過jQuery示例代碼演示outerWidth()函數(shù)的具體用法,介紹的非常詳細(xì),有需要的朋友可以借鑒2015-07-07Jquery 設(shè)置標(biāo)題的自動翻轉(zhuǎn)
我們平時在開發(fā)web程序的時候,想把一個新聞源滾動顯示新聞的條目的標(biāo)題及內(nèi)容摘要,而且是每次一條,有點類似csdn的滾動廣告。2009-10-10JQuery中html()方法使用不當(dāng)帶來的陷阱
html方法當(dāng)不傳參數(shù)時用來獲取元素的html內(nèi)容2011-04-04