我正在制作一个 Windows 8 横向滚动样式的网页设计。我需要帮助编写内容在矩形中出现的方式。内容应逐个向下滚动,并在标题之间稍作停顿,以便用户能够查看它并在到达最后一个标题后改变方向。
这里我们的代码:
<html>
<head>
<style type="text/css">
body
{
background-color:blue;
color:white;
overflow:hidden;
}
span.start
{
font-size:280%;
font-family:helvetica;
}
div.spacer
{
margin-top:50px;
}
div.spacer-left
{
margin-left:30px;
}
div.box1
{
width:400px;
height:200px;
display:inline-block;
margin-left:10px;
overflow:hidden;
}
div.box2
{
width:200px;
height:200px;
display:inline-block;
margin-left:10px;
}
#cyan
{
background-color:cyan;
}
#purple
{
background-color:purple;
}
#lime
{
background-color:lime;
}
#orange
{
background-color:orange;
}
#red
{
background-color:red;
}
#yellow
{
background-color:yellow;
}
div.length
{
position:fixed;
width:5000px;
-moz-transition:all 2s;
-webkit-transition:all 2s;
}
div.click
{
font-size:500%;
text-decoration:none;
color:white;
position:absolute;
margin-left:1300px;
margin-top:-400px;
}
#length:target
{
margin-left:-1000px;
}
div.content
{
position:relative;
height:500px;
font-size:200%;
}
</style>
<script type="text/javascript">
var rate = 0;
function scroll() {
setInterval(function (){
document.getElementById('content').style.marginTop = rate;
rate--;
}, 10);
}
onload=scroll();
</script>
</head>
<body>
<div class="length" id="length">
<div class="spacer-left">
<span class="start">Start</span>
<div class="spacer"></div>
<div class="box1" id="cyan">
<div class="content" id="content">
<h1>Some content</h1>
<h1>Some more content</h1>
<h1>Even more content</h1>
</div>
</div>
<div class="box1" id="purple">
</div>
<div class="box2" id="lime">
</div>
<div class="box2" id="orange">
</div>
<br>
<div class="box2" id="red">
</div>
<div class="box1" id="yellow">
</div>
<div class="box2" id="cyan">
</div>
<div class="box1" id="purple">
</div>
<br>
<div class="box1" id="lime">
</div>
<div class="box2" id="orange">
</div>
<div class="box1" id="yellow">
</div>
<div class="box2" id="red">
</div>
<a href="#length"><div class="click" id="click">
>
</div></a>
</div>
</div>
</body>
</html>
在这段代码中,内容只是滚动,中间没有停顿。