日期:2014-05-17 浏览次数:20757 次
<style type="text/css">
.newlistdiv { width:565px; height:200px; padding:0 40px; position:relative; float:left;}
.newlistdiv .btnLeft { width:25px; height:40px;position:absolute; left:0px; top:80px;}
.newlistdiv .btnRight { width:25px; height:40px;position:absolute; right:0px; top:80px;}
.newcnt { width:565px; height:200px; position:relative; overflow:hidden; }
.newcnt .newlist { width:800%; height:200px; position:absolute; top:0; left:0;}
.newlist .newtextall { width:565px; float:left; position:relative; z-index:0;height:200px;}
</style>
<script type="text/javascript" src="http://www.coding123.net/js/jquery.js"></script>
<script type="text/javascript">
jQuery(function () {
jQuery.fn.news = function (parent_div, page_size) {
var positionleft = 0;
var o = jQuery(this).find(parent_div);
var w = o.width();
var showbox = jQuery(this).find('.newlist');
var len = showbox.find('.newtextall').length;
var page_count = Math.ceil(len / page_size);
showbox.width(w * page_count);
var midItem = showbox.find('.newtextall').slice(1, len - 1); //中间元素
midItem.css('font-weight', 'bold')
//向左滚动
jQuery(this).find('.btnLeft').click(function () {
if (!showbox.is(':animated')) {
if (positionleft == 0) {
positionleft = positionleft - w * (page_count - 1);
&