码迷,mamicode.com
首页 > 其他好文 > 详细

类似边框栏弹出

时间:2016-10-06 00:20:57      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

一个类似边框弹出的小效果

<div id="box"></div>
<style>
        #box{
            width: 300px;
            height: 200px;
            background-color: skyblue;
            position: absolute;
            left: -250px;
            top: 0;
            cursor: pointer;
        }
    </style>
<script>
            window.onload=function(){
                var box=document.getElementById("box");
                var box_left=-250;
                var times;
                var back_times;
                box.onmouseover=function(){
                    clearInterval(back_times);
                    clearInterval(times);
                    times=setInterval(function(){
                        box_left+=10;
                    box.style.left=box_left+‘px‘;
                    if(box_left>=0){
                        clearInterval(times);
                    }
                    },10)
                }
                box.onmouseout=function(){
                    clearInterval(times)
                    clearInterval(back_times);
                    back_times=setInterval(function(){
                        box_left-=10;
                        box.style.left=box_left+‘px‘;
                        if(box_left<=-250){
                            clearInterval(back_times);
                        }
                    },10)
                }
            }
    </script>

 

类似边框栏弹出

标签:

原文地址:http://www.cnblogs.com/lovelx256/p/5933138.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!