jQuery實(shí)現(xiàn)流動(dòng)虛線框的方法
本文實(shí)例講述了jQuery實(shí)現(xiàn)流動(dòng)虛線框的方法。分享給大家供大家參考。具體分析如下:
在百度UEditor的首頁看到一個(gè)流動(dòng)的虛線框的效果,所以自己用jQuery嘗試也寫一個(gè),效果如下:
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);
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
- jquery調(diào)取json數(shù)據(jù)實(shí)現(xiàn)省市級(jí)聯(lián)的方法
- Jquery 實(shí)現(xiàn)checkbox全選方法
- jQuery+ajax實(shí)現(xiàn)動(dòng)態(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果凍抖動(dòng)效果實(shí)現(xiàn)方法
- jquery隔行換色效果實(shí)現(xiàn)方法
相關(guān)文章
在次封裝easyui-Dialog插件實(shí)現(xiàn)代碼
在次封裝easyui-Dialog插件實(shí)現(xiàn)代碼,需要的朋友可以參考下。2010-11-11
關(guān)于JQuery($.load)事件的用法和分析
本篇文章小編為大家介紹,關(guān)于JQuery($.load)事件的用法與分析,有需要的朋友可以關(guān)注一下2013-04-04
jquery.cookie.js 操作cookie實(shí)現(xiàn)記住密碼功能的實(shí)現(xiàn)代碼
jquery.cookie.js操作cookie實(shí)現(xiàn)記住密碼功能,很簡(jiǎn)單很強(qiáng)大,喜歡的朋友可以參考下。2011-04-04
JQuery實(shí)現(xiàn)動(dòng)態(tài)漂浮廣告
這篇文章主要為大家詳細(xì)介紹了JQuery實(shí)現(xiàn)動(dòng)態(tài)漂浮廣告,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
JQuery使用屬性addClass、removeClass和toggleClass實(shí)現(xiàn)增加和刪除類操作示例
這篇文章主要介紹了JQuery使用屬性addClass、removeClass和toggleClass實(shí)現(xiàn)增加和刪除類操作,涉及jquery事件響應(yīng)及頁面元素屬性動(dòng)態(tài)操作相關(guān)使用技巧,需要的朋友可以參考下2019-11-11
jQuery實(shí)現(xiàn)html表格動(dòng)態(tài)添加新行的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)html表格動(dòng)態(tài)添加新行的方法,涉及jQuery鼠標(biāo)事件及頁面元素的操作技巧,需要的朋友可以參考下2015-05-05
詳談jQuery操縱DOM元素屬性 attr()和removeAtrr()方法
這篇文章主要詳細(xì)介紹了jQuery操縱DOM元素屬性 attr()和removeAtrr()方法,非常的全面細(xì)致,在這里推薦給小伙伴們。2015-01-01

