不能透明 帮看看吧
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<!-- <link href="./css/005.css" rel="stylesheet"> -->
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#div1{
width: 200px;
height: 200px;
background: red;
filter: alpha(opacity:30);
/*透明度为0.3*/
opacity: 0.3;
}
</style>
<script>
/**
*
* @authors Your Name (you@example.org)
* @date 2016-03-27 22:46:46
* @version $Id$
*/
// 打开窗口后直接加载的函数
window.onload=function () {
var oDiv=document.getElementByid('div1');
oDiv.onmouseover=function(){
startMove(100);
}
oDiv.onmouseout=function(){
startMove(30);
}
}
var alpha=30;
var timer=null;
function startMove(xTarget) {
clearInterval(timer);
var oDiv=document.getElementByid('div1');
timer=setInterval(function(){
var speed=0;
if (alpha>xTarget) {
speed=-10;
} else {
speed=10;
}
if (alpha==xTarget) {
clearInterval(timer);
} else {
alpha+=speed;
oDiv.style.filter="alpha(opacity:'+alpha+')";
oDiv.style.opacity=alpha/100;
}
},30)
}
</script>
</head>
<body>
<div id="div1">
</div>
</body>
</html>