Ⅰ 网页制作 让网页上的图片自动变换的代码
HTML中图片轮播代码如下:
<!DOCTYPEhtml>
<html>
<head><title>图片轮播代码</title>
<metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0">
</head>
<styletype="text/css">
body{max-width:640px;margin:0auto;}
#lunboulli{width:100%;list-style:none;width:640px;height:250px;background-color:#f00;text-align:center;}
#lunboulli:not(:first-child){display:none;}</style><body><divid="lunbo">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul></div><scripttype="text/javascript">
//因为使用了document,所以js需要放在需要执行的代码下面生效才能生效
varli=document.getElementById('lunbo').getElementsByTagName("li");
varnum=0;
varlen=li.length;
setInterval(function(){
li[num].style.display="none";
num=++num==len?0:num;
li[num].style.display="inline-block";
},3000);//切换时间
</script>
</body>
</html>
Ⅱ 怎么用html和css做图片轮播
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css实现轮播效果</title> <style type="text/css"> .one { position: absolute; width: 500px; height: 400px; overflow: hidden; } .one_cantent img { width: 500px; height: 300px; float: left; } .one_cantent { width: 2500px; height: 400px; position: absolute; left: 0px; animation-name: move; animation-ration: 10s; animation-iteration-count: infinite; } @keyframes move { 0% { left: 0px; } 25% { left: -500px; } 50% { left: -1000px; } 75% { left: -1500px; } 100% { left: -2000px } } </style> </head> <body> <div> <div> <img src="./image/0.jpg"> <img src="./image/1.jpg"> <img src="./image/2.jpg"> <img src="./image/3.jpg"> <img src="./image/4.jpg"> </div> </div> </body> </html>
Ⅲ HTML图片轮播代码怎么写
html部分
<divid="container">
<divclass="sections">
<divclass="section"id="section0"><h3>thisisthepage1</h3></div>
<divclass="section"id="section1"><h3>thisisthepage2</h3></div>
<divclass="section"id="section2"><h3>thisisthepage3</h3></div>
<divclass="section"id="section3"><h3>thisisthepage4</h3></div>
</div>
</div>
css部分
*{
padding:0;
margin:0;
}
html,body{
height:100%;
}
#container{
width:100%;
height:500px;
overflow:hidden;
}
.sections,.section{
height:100%;
}
#container,.sections{
position:relative;
}
.section{
background-color:#000;
background-size:cover;
background-position:50%50%;
text-align:center;
color:white;
}
#section0{
background-image:url('images/1.jpg');
}
#section1{
background-image:url('images/2.jpg');
}
#section2{
background-image:url('images/3.jpg');
}
#section3{
background-image:url('images/4.jpg');
}
.pagesli{list-style-type:none;width:10px;height:10px;border-radius:10px;background-color:white}.pagesli:hover{box-shadow:005px2pxwhite}.pagesli.active{background-color:orange;box-shadow:005px2pxorange}.pages{position:absolute;z-index:999}.pages.horizontal{left:50%;transform:translateX(-50%);bottom:5px}.pages.horizontalli{display:inline-block;margin-right:10px}.pages.horizontalli:last-child{margin-right:0}.pages.vertical{right:5px;top:50%;transform:translateY(-50%)}.pages.verticalli{margin-bottom:10px}.pages.verticalli:last-child{margin-bottom:0}
JS部分
<scriptsrc="js/jquery-1.11.0.min.js"type="text/javascript"></script>
//引入pageSwitch.min.js
<script>
$("#container").PageSwitch({
direction:'horizontal',
easing:'ease-in',
ration:1000,
autoPlay:true,
loop:'false'
});
</script>
Ⅳ html5如何实现图片轮播
静态获取图片写法,给定图片的个数,用js实现轮播图自动转换。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<!-- *******设置样式********** -->
<style type="text/css">
.show_div{
width: 400px;
height: 400px;
margin: 0 auto;
border: 2px solid block;
overflow: hidden;
}
.scroll_div{
width: 2000px;
height: 400px;
}
.scroll_div img{
width: 400px;
height: 400px;
float: left;
}
</style>
<!-- end -->
</head>
<body>
<div class="show_div">
<div class="scroll_div">
<img src="img/b.jpg" alt="">
<img src="img/c.jpg" alt="">
<img src="img/d.jpg" alt="">
<img src="img/a.jpg" alt="">
<img src="img/b.jpg" alt="">
</div>
</div>
</body>
<!-- *********js代码******** -->
<script type="text/javascript">
var scrollDiv = document.getElementsByClassName("scroll_div")[0];
// 定义初始值
var left =0;
// 定义一个定时器 走一步
function move(){
var timer = setInterval(function(){
left --;
if (left <= -1600) {
left = 0;
}
if (left % -400 == 0) {
clearInterval(timer);
timer = null;
}
scrollDiv.style.marginLeft = left + "px";
},10);
}
// 定义一个定时器 每隔固定时间 走一张
setInterval(function(){
move();
},5000);
</script>
</html>