基于jquery的滚动新闻列表

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>vTicker</title>
<style type="text/css" media="all">
body,html {
padding: 0;
margin: 0;
}

body {
background: #cccccc;
}

#news  - container {
width: 400px;
margin: auto; margin - top : 10px;
border: 5px solid #333333;
}

#news  - container ul li div {
border: 1px solid #aaaaaa;
background: #ffffff;
}
</style>
<script type="text/javascript" src="demo_files/jquery.js">
        </script>
<script type="text/javascript" src="demo_files/jquery.vticker-min.js">
        </script>
<script type="text/javascript">
            $(function() {
                $('#news-container').vTicker({
                    speed: 500,
                    pause: 3000,
                    animation: 'fade',
                    mousePause: false,
                    showItems: 3
                });
                $('#news-container1').vTicker({
                    speed: 700,
                    pause: 4000,
                    animation: 'fade',
                    mousePause: false,
                    showItems: 1
                });
            });
        </script>
</head>


<body>
<div id="news-container1">
<ul>
<li>
新闻标题1
</li>
<li>
新闻标题2
</li>
<li>
新闻标题3
</li>
<li>
新闻标题4
</li>
<li>
新闻标题5
</li>
</ul>
</div>
<div style="overflow: hidden; position: relative; height: 24px;"
id="news-container">
<ul style="position: absolute; margin: 0pt; padding: 0pt; top: 0px;">
<li
style="margin: 0pt; padding: 0pt; height: 18px; display: list-item;">
<div>
4) 摩洛哥塞拉,艺术家在一场为流浪儿童募捐的马戏节目中表演
</div>
</li>
<li
style="margin: 0pt; padding: 0pt; height: 18px; display: list-item;">
<div>
1) 印度克什知自己的孩子在骚乱中丧生时痛不欲生
</div>
</li>
<li
style="margin: 0pt; padding: 0pt; height: 18px display: list-item;">
<div>
2) 昆明警方近日捣毁了寻甸县的“洪兴帮”黑恶势力团伙
</div>
</li>
<li style="margin: 0pt; padding: 0pt; height: 18px">
<div>
3) 湖北武汉汉口龙王庙景区观景平台上,市民聚集在江边观看两江洪峰过汉
</div>
</li>
</ul>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个使用jQuery创建新闻列表的示例: ```html <!DOCTYPE html> <html> <head> <title>jQuery新闻列表</title> <style> * { padding: 0; margin: 0; list-style: none; } a { text-decoration: none; } .clearfix::after { content: ""; clear: both; display: block; width: 0; height: 0; } .new-list, .btns { width: 500px; margin: 50px auto; } .new-list li { border-bottom: 1px solid gainsboro; padding: 20px 0; } .new-list li:last-child { border-bottom: none; } .new-list li img { float: left; width: 100px; margin-right: 10px; } .news-dec p { color: gainsboro; } i { color: red; } </style> </head> <body> <ul class="new-list"> <li> <img src="news1.jpg" alt="News 1"> <div class="news-dec"> <h3>News 1</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc id aliquam lacinia, nisl nunc tincidunt urna, id lacinia nunc nunc id lectus.</p> </div> </li> <li> <img src="news2.jpg" alt="News 2"> <div class="news-dec"> <h3>News 2</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc id aliquam lacinia, nisl nunc tincidunt urna, id lacinia nunc nunc id lectus.</p> </div> </li> <li> <img src="news3.jpg" alt="News 3"> <div class="news-dec"> <h3>News 3</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc id aliquam lacinia, nisl nunc tincidunt urna, id lacinia nunc nunc id lectus.</p> </div> </li> </ul> <div class="btns"> <button class="prev">上一页</button> <button class="next">下一页</button> </div> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { var currentIndex = 0; var itemsPerPage = 1; var $list = $('.new-list li'); var totalItems = $list.length; var totalPages = Math.ceil(totalItems / itemsPerPage); function showPage(page) { var startIndex = (page - 1) * itemsPerPage; var endIndex = startIndex + itemsPerPage; $list.hide(); $list.slice(startIndex, endIndex).show(); } function updateButtons() { $('.prev').prop('disabled', currentIndex === 0); $('.next').prop('disabled', currentIndex === totalPages - 1); } showPage(1); updateButtons(); $('.prev').click(function() { if (currentIndex > 0) { currentIndex--; showPage(currentIndex + 1); updateButtons(); } }); $('.next').click(function() { if (currentIndex < totalPages - 1) { currentIndex++; showPage(currentIndex + 1); updateButtons(); } }); }); </script> </body> </html> ``` 此示例使用jQuery创建了一个新闻列表,每页显示一个新闻项。通过点击上一页和下一页按钮,可以切换显示的新闻项。CSS样式定义了列表项的样式,包括图片、标题和描述。JavaScript代码处理分页逻辑,并更新按钮的状态。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值