如何在HTML和CSS里面插入喜欢的js图片轮播效果
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#tab { overflow:hidden; width:400px; height:250px; position:relative; float:left;}
#tab>img:not(:first-child){ display:none; }
</style>
<script>
window.onload = function(){
var images = document.getElementsByTagName('img');
var pos = 0;
var len = images.length;
setInterval(function(){
images[pos].style.display = 'none';
pos = ++pos == len ? 0 : pos;
images[pos].style.display = 'inline';
},1000);
};
</script>
</head>
<body>
<div id="tab">
<img src="img/01.jpg" width="400" height="250"/>
<img src="img/02.jpg" width="400" height="250"/>
<img src="img/03.jpg" width="400" height="250"/>
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#tab { overflow:hidden; width:400px; height:250px; position:relative; float:left;}
#tab>img:not(:first-child){ display:none; }
</style>
<script>
window.onload = function(){
var images = document.getElementsByTagName('img');
var pos = 0;
var len = images.length;
setInterval(function(){
images[pos].style.display = 'none';
pos = ++pos == len ? 0 : pos;
images[pos].style.display = 'inline';
},1000);
};
</script>
</head>
<body>
<div id="tab">
<img src="img/01.jpg" width="400" height="250"/>
<img src="img/02.jpg" width="400" height="250"/>
<img src="img/03.jpg" width="400" height="250"/>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询