在html中怎么通过js让图片透明度渐变
1个回答
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>简单透明度渐变</title>
</head>
<style type="text/css">
*{margin:0;padding:0;}
#oDiv{width:200px;height:200px;margin:0 auto;background:#000;}
</style>
<body>
<div id="oDiv" style="opacity:1;">Lee</div>
</body>
<script type="text/javascript">
window.onload = function(){
var timer = setInterval(colorLiner,20);
var val = 100;
function colorLiner(){
if(val >= 0){
var oDiv = document.getElementById('oDiv');
oDiv.style.opacity = val/100;
val--;
}
}
}
</script>
</html>
<html>
<head>
<meta charset="utf-8" />
<title>简单透明度渐变</title>
</head>
<style type="text/css">
*{margin:0;padding:0;}
#oDiv{width:200px;height:200px;margin:0 auto;background:#000;}
</style>
<body>
<div id="oDiv" style="opacity:1;">Lee</div>
</body>
<script type="text/javascript">
window.onload = function(){
var timer = setInterval(colorLiner,20);
var val = 100;
function colorLiner(){
if(val >= 0){
var oDiv = document.getElementById('oDiv');
oDiv.style.opacity = val/100;
val--;
}
}
}
</script>
</html>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询