87,993
社区成员
发帖
与我相关
我的任务
分享<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>1</title>
<style>
*{margin:0;padding:0;}
#aa{width:200px;height:200px;background:red;position:relative;left:-200px;top:0;}
#aa span{width:20px;height:50px;background:blue;position:absolute;left:200px;top:75px;}
</style>
</head>
<body>
<div id="aa"><span>分享</span></div>
<script>
var aa =document.getElementById("aa");
var time = null;
aa.onmouseover=function(){
time=setInterval(function(){
if(aa.offsetLeft>=0){
clearInterval(time);
}else{
aa.style.left=aa.offsetLeft+10+"px";
}
},20);
}
aa.onmouseout=function(){
clearInterval(time);
aa.style.left=-200+"px";
};
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.open{
animation: expand 0.8s forwards;
}
@keyframes expand {
0% {left:-200px;}
100% {left:0px;}
}
*{margin:0;padding:0;}
#aa{width:200px;height:200px;background:red;position:relative;left:-200px;top:0;}
#aa span{width:20px;height:50px;background:blue;position:absolute;left:200px;top:75px;}
</style>
</head>
<body>
<div id="aa" onmouseover="this.className='open';" onmouseout="this.removeAttribute('class');"><span>share</span></div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>1</title>
<style>
*{margin:0;padding:0;}
#aa{width:200px;height:200px;background:red;position:relative;left:-200px;top:0;}
#aa span{width:20px;height:50px;background:blue;position:absolute;left:200px;top:75px;}
</style>
</head>
<body>
<div id="aa"><span>分享</span></div>
<script>
var aa =document.getElementById("aa");
var time = null;
aa.onmouseenter=function(){
clearInterval(time);
time=setInterval(function(){
if(aa.offsetLeft>=0){
clearInterval(time);
}else{
aa.style.left=aa.offsetLeft+10+"px";
}
},20);
}
aa.onmouseleave=function(){
clearInterval(time);
aa.style.left=-200+"px";
};
</script>
</body>
</html>