如果你使用像 jQuery 这样的库来做你的 JavaScript 肮脏的工作,那么我会在某种程度上提出一些建议。
<style type="text/css">
ul {
margin:0;
padding:0;
list-style:none;
width:300px;
height:300px;
overflow:hidden;
border:#000 1px solid;
}
ul li{
margin:0;
padding:0;
list-style:none;
width:300px;
height:300px;
display:none;
}
.active{
display:block;
}
</style>
<ul>
<li class="active">1 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </li>
<li>2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </li>
<li>3 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </li>
<li>4 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </li>
</ul>
<script type="text/javascript">
setInterval(function()
{
if($('ul li[class="active"]').is(':last-child'))
{
$('ul li[class="active"]').removeClass('active');
$('ul li:first').addClass('active')
}
else
{
$('ul li[class="active"]').removeClass('active').next().addClass('active');
}
},5000);
</script>
Ipsum 文本可以是您从查询中回显的结果,您可以将整个无序列表放入您的 div 中,您只需要相应地调整大小以满足您的需求。
jsFiddle DEMO