JS滑入滑出效果
来源:互联网 发布:重庆java工程师招聘 编辑:程序博客网 时间:2024/06/03 12:48
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#div1 span{
width: 50px;
height: 50px;
background: blue;
position: absolute;
left: 200px;
top: 75px;
}
#div1{
width: 200px;
height: 200px;
background: red;
position: absolute;
left: -200px;
top: 0;
}
</style>
<script type="text/javascript">
window.onload=function(){
var odiv = document.getElementById("div1");
odiv.onmouseover = function(){
startMove(0);
}
odiv.onmouseout = function(){
startMove(-200);
}
}
var timer = null;
function startMove(iTarget){
clearInterval(timer);
var odiv = document.getElementById("div1");
timer = setInterval(function(){
var speed = 0;
if(odiv.offsetLeft > iTarget){
speed = -10;
}else{
speed = 10;
}
if(odiv.offsetLeft == iTarget){
clearInterval(timer);
}else{
odiv.style.left = odiv.offsetLeft+speed+'px';
}
},30);
}
</script>
</head>
<body>
<div id="div1">
<span id="share">
分享
</span>
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#div1 span{
width: 50px;
height: 50px;
background: blue;
position: absolute;
left: 200px;
top: 75px;
}
#div1{
width: 200px;
height: 200px;
background: red;
position: absolute;
left: -200px;
top: 0;
}
</style>
<script type="text/javascript">
window.onload=function(){
var odiv = document.getElementById("div1");
odiv.onmouseover = function(){
startMove(0);
}
odiv.onmouseout = function(){
startMove(-200);
}
}
var timer = null;
function startMove(iTarget){
clearInterval(timer);
var odiv = document.getElementById("div1");
timer = setInterval(function(){
var speed = 0;
if(odiv.offsetLeft > iTarget){
speed = -10;
}else{
speed = 10;
}
if(odiv.offsetLeft == iTarget){
clearInterval(timer);
}else{
odiv.style.left = odiv.offsetLeft+speed+'px';
}
},30);
}
</script>
</head>
<body>
<div id="div1">
<span id="share">
分享
</span>
</div>
</body>
</html>
0 0
- JS滑入滑出效果
- js效果
- js 效果
- js效果
- js效果
- js效果
- JS--JS动态效果
- JS广告跟随效果
- js滚动的效果
- js菜单效果
- js加载效果
- 窗口震颤效果JS
- js文字幻灯效果
- js滚动效果
- js实现滚动效果
- JS图片倒影效果
- JS拖曳效果
- JS树效果
- MAC下安装MAVEN
- 用THREE.Shape画二维圆角矩形
- 浅谈单片机应用程序架构
- 信号
- 单点搭建HADOOP系统
- JS滑入滑出效果
- PAT 乙级 说反话
- Activity重建之殇
- POJ 3193 字符串排序+比较
- session在页面重定向后会清空作用域中的值吗?
- 2-sat(任意可能性输出o(n))
- JAVA程序员必看的15本书-JAVA自学书籍推荐
- nexus上传报Error code 400, Bad Request问题
- Mybatis配置及功能详解