jQuery实现流动虚线框的方法
作者:bea
本文实例讲述了jQuery实现流动虚线框的方法。分享给大家供大家参考。具体分析如下: 在百度UEditor的首页看到一个流动的虚线框的效果,所以自己用jQuery尝试也写一个,效果如下: css: .dashed-box{width:500px;height:100px;overflow:hidden;position:relative;}.dashed-top{width:2000px;height:0px;border-bottom:2px #ccc dashed;p
本文实例讲述了jQuery实现流动虚线框的方法。分享给大家供大家参考。具体分析如下:
在百度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程序设计有所帮助。
猜你喜欢
您可能感兴趣的文章:
- 使用mouse事件实现简单的鼠标经过特效
- js实现屏幕自适应局部代码分享
- jQuery弹出框代码封装DialogHelper
- jquery中animate的stop()方法作用实例分析
- javascript中sort()的用法实例分析
- JavaScript中的值是按值传递还是按引用传递问题探讨
- javascript结合fileReader 实现上传图片
- 使用JavaScript+canvas实现图片裁剪
- js判断手机和pc端选择不同执行事件的方法
- 项目中常用的JS方法整理
- jQuery实现带滚动线条导航效果的方法
- jquery实现拖拽调整Div大小
- jQuery中$.click()无效问题分析
- Eclipse配置Javascript开发环境图文教程
- js操作滚动条事件实例
- jQuery调取jSon数据并展示的方法
- jquery通过load获取文件的内容并跳到锚点的方法
- 浅谈Javascript 数组与字典
- javascript 数组操作详解