首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

求:多个TABLE左右手动轮播 滚动 切换的代码解决方案

2013-02-04 
求:多个TABLE左右手动轮播 滚动 切换的代码想找一个,用JS或者JQUERY写的,多个TABLE左右滚动切换的代码。就

求:多个TABLE左右手动轮播 滚动 切换的代码
想找一个,用JS或者JQUERY写的,
多个TABLE左右滚动切换的代码。
就是TABLE的左边和右边有 ”《“,“》”这样的按钮,
点按钮的时候,左右滚动切换TABLE。
请给链接或者代码,
谢谢。

昨天有人提供这个链接:
http://slidesjs.com/examples/linking/#5 

但是HTML头部代码为:
<!DOCTYPE html>
<html lang="en">
<head>
这种标准,所以,到我的代码里不能用。
原来的布局全部变了。

我想要,
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
这样标准的代码。
谢谢。

[解决办法]


<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);
                        midItem.hide(); //隐藏中间的


                        showbox.animate({
                            left: -w
                        }, 500, function () { showbox.css('left', positionleft); midItem.show(); /*动画结束后再显示出来*/ });
                    } else {
                        positionleft = positionleft + w
                        showbox.animate({
                            left: positionleft
                        }, 500);
                    }
                }
            });
            //向右滚动
            jQuery(this).find('.btnRight').click(function () {
                if (!showbox.is(':animated')) {
                    if (positionleft == -w * (page_count - 1)) {
                        positionleft = 0;
                        midItem.hide(); //隐藏中间的
                        showbox.css('left', -w); //要重设left的位置
                        showbox.animate({
                            left: 0
                        }, 500, function () { midItem.show(); });
                    } else {
                        positionleft = positionleft - w;
                        showbox.animate({
                            left: positionleft


                        }, 500);
                    }
                }
            });
        }
        jQuery(".newlistdiv").each(function () { jQuery(this).news('.newcnt', 1); });
    })
</script>


页面代码

<div class="newlistdiv">
<div class="btnLeft">L</div>
<div class="btnRight">R</div>
<div class="newcnt">
<div class="newlist">
<div class="newtextall" style="background:#666666">
            <table>
              <tr>
                <td>1</td>
              </tr>
            </table>
            </div>
<div class="newtextall" style="background:#777777">
            <table>
              <tr>
                <td>2</td>
              </tr>
            </table>
            </div>
<div class="newtextall" style="background:#888888">
            <table>
              <tr>
                <td>3</td>
              </tr>
            </table>
            </div>
<div class="newtextall" style="background:#999999">
            <table>
              <tr>
                <td>4</td>
              </tr>
            </table>
            </div>
<div class="newtextall" style="background:#aaaaaa">
            <table>
              <tr>
                <td>5</td>


              </tr>
            </table>
            </div>
</div>
</div>
</div>

热点排行