您可以使用 jQuery 来做到这一点。
基本上,最初使用 CSS 将内容设置为从左侧偏移 800 像素。然后使用 jQuery animate
,我们将内容滑入,直到从左侧的偏移量为 0px。您可以增加或减少持续时间以改变滑入的速度。
jQuery
$(document).ready(function() {
$("#one").animate({left: "0"}, {
duration: 2000
});
$("#two").animate({left: "0"}, {
duration: 2250
});
$("#three").animate({left: "0"}, {
duration: 2500
});
});
CSS
.bcontent > div{
position: relative;
display: inline-block; /* to display the 3 div's in same line */
height: 200px; /* height, width and border just added for demo, not mandatory */
width: 100px;
border: 1px solid black;
left: 110%; /* Added to avoid the width issue pointed out by DRP96 */
}
.bcontent{
width: 100%;
overflow: hidden; /* added to make the content hidden initially and avoid scroll-bar */
}
$(document).ready(function() {
$("#one").animate({
left: "0"
}, {
duration: 2000
});
$("#two").animate({
left: "0"
}, {
duration: 2250
});
$("#three").animate({
left: "0"
}, {
duration: 2500
});
});
footer {
bottom: 0px;
font-size: 20px;
}
.bcontent {
width: 100%;
overflow: hidden;
}
.bcontent > div {
position: relative;
display: inline-block;
height: 200px;
width: 100px;
left: 110%;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<div class="row">
<h1 class='logo'>Site Name</h1>
<div class='bcontent'>
<div id="one" class="span4">One Content</div>
<div id="two" class="span4">Two</div>
<div id="three" class="span4">Three</div>
</div>
<footer>Copy rights</footer>
</div>