我们看到过图片的轮换,有的时候也需要div块像图片一样轮换,所以我们可以通过js来控制效果
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="./css/iuapmobile.um.css">
<link rel="stylesheet" href="./css/font-icons.css">
<script src="./js/jquery.min.js" ></script>
<script src="./js/Frameworks/iuapmobile.frameworks.ui.js" ></script>
<style>
#changebox {
width: 455px;
height: 415px;
overflow: hidden;
position: relative;
}
#changebox #changeAction {
width: 910px;
height: 415px;
position: absolute;
}
#changebox #changeAction #links {
width: 455px;
height: 415px;
float: left;
background-color: #777777;
}
#changebox #changeAction #links2 {
width: 455px;
height: 415px;
float: left;
background-color: #4CD964;
}
</style>
</head>
<body>
<div class="um-win" id="index">
<div id="changebox">
<div id="changeAction" style="left:0px;">
<div id="links">
页面1
</div>
<div id="links2">
页面2
</div>
</div>
</div>
<button id="button1" style="width: 100px;" οnclick="abc()">
div2
</button>
<button id="button2" οnclick="efg()" style="width: 100px;display: none">
div1
</button>
</div>
<script>
window.tt
function moveStyleLeft() {
var obj = document.getElementById('changeAction');
if (parseInt(obj.style.left) < 0) {
obj.style.left = parseInt(obj.style.left) + 10 + "px";
}
}
function moveStyleRigtht() {
var obj = document.getElementById('changeAction');
if (parseInt(obj.style.left) > -458) {
obj.style.left = parseInt(obj.style.left) - 10 + "px";
}
}
function efg() {
clearInterval(window.tt);
tt = setInterval('moveStyleLeft()', 1);
document.getElementById('button1').style.display = '';
document.getElementById('button2').style.display = 'none';
}
function abc() {
clearInterval(window.tt);
tt = setInterval('moveStyleRigtht()', 1);
document.getElementById('button1').style.display = 'none';
document.getElementById('button2').style.display = '';
}
</script>
</body>
</html>