沒有透明度改變的效果,求大神答疑解惑,萬分感謝
<!DOCTYPE html>
<html>
<head>
<title>opacity</title>
<style type="text/css">
#div1{
? ?height: 200px;
? ?width: 200px;
? ?background-color:red;
? ?filter:alpha(opacity:20);
? ?opacity: 0.2;
}
</style>
</head>
<body>
<div id="div1"></div>
<script>
window.onload=function() {
var oDIV=document.getElementById("div1");
? ? oDIV.onmouseover=onMove(100);
? ? oDIV.onmouseout=onMove(20);
}
var oDIV=document.getElementById("div1");
var timer=null;
var alpha=20;
var speed=0;
function onMove(iTarget){
? ?clearInterval(timer);
? ?timer=setInterval(function(){
? ? ? if (alpha>iTarget) {
? ? speed=-10;
? ? } else{
? ? speed=10;
? ? }
? ? if (alpha==iTarget) {
? ? clearInterval(timer);
? ?}
? ?else{
? ? alpha+=speed;
? ? oDIV.style.filter="alpha(opacity:"+alpha+")";
? ? oDIV.style.opacity=alpha/100;
? ?}
? ?},30)
}
</script>
</body>
</html>
2015-12-09
我真不知道上面那些人是在回答些什么。代碼不看就說瀏覽器不支持?幫你改了一下。不理解可以問
2015-12-09
filter:alpha(opacity=20); ?/* IE 瀏覽器支持 */ ;
-moz-opacity:0.4; ? ? ? ? ?/* 遨游瀏覽器 火狐瀏覽器 支持 */ ;
opacity: 0.4; ? ? ? ? ? ? ?/* 支持CSS3的瀏覽器(FF 1.5也支持)*/”>
2015-12-09
瀏覽器不支持這個 透明