<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>shareicon</title>
</head>
<style type="text/css">
*{
margin:0px;padding:0px;font:14px "微软雅黑" normal;
}
#content{
position:absolute;
left:0px;
top:200px;
width:200px;
height:200px;
background-color: #cc3399;
opacity: 0.4;
}
#content span{
position:absolute;
left:200px;
top:37.5%;
width:20px;
height:25%;
padding-top:10px;
background-color: #99cc00;
text-align: center;
}
}
</style>
<script type="text/javascript">
window.onload=function(){
var mBox=document.getElementById("content");
mBox.onmouseover=function(){
changeOpacity(1);
}
mBox.onmouseout=function(){
changeOpacity(0.4);
}
var timer=null;
var mOpacity=0.4;
function changeOpacity(itarget){
clearInterval(timer);
timer=setInterval(function(){
var speed=0;
if(mOpacity<itarget){
speed=0.1;
}else{
speed=-0.1;
}
if(mOpacity==itarget){
clearInterval(timer);
}else{
mOpacity+=speed;
mBox.style.opacity=mOpacity;
}
},300)
}
}
</script>
<body>
<div id="content">
<span>分享</span>
</div>
</body>
</html>