坑爹的问题,jquery样式与css样式的神秘问题

<!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>
    <title>图片切换</title>
    <script src="jquery-1.8.0.js" type="text/javascript"></script>
    <link href="picchange.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var picCurrent = 0;
        var picTotal = 8;
        var step = -1;
        var interval;
        function picSelect() {
            setSelectClass();
            picAnimate();
            return false;
        }
        function picMove() {
            picCurrent = (picCurrent + step + picTotal) % picTotal;
            picSelect();
        }
        function setSelectClass() {
            var $a = $("#divLink").children("a");
            $a.removeClass("picselect")
            $a.eq(picCurrent).addClass("picselect")
        }
        function picAnimate() {
            $("#divImg").stop().animate({ left: -((picCurrent) * 1000)}, "1000");
        }
        function picRun(functionName) {
            interval = setInterval(picMove, "3000");
        }
        function picStop() {
            clearTimeout(interval);
        }
        $(document).ready(function () {
            $("#divLink").children("a").click(function() {
                picStop();
                picCurrent = $(this).index();
                picSelect();
                picRun();
            });
            picRun();
        });
    </script>
</head>
<body>
    <div id="picMain">
        <div id="divImg">
            <img src="images/pic1.jpg" />
            <img src="images/pic2.jpg" />
            <img src="images/pic3.jpg" />
            <img src="images/pic4.jpg" />
            <img src="images/pic5.jpg" />
            <img src="images/pic6.jpg" />
            <img src="images/pic7.jpg" />
            <img src="images/pic8.jpg" />
        </div>
        <div id="divLink">
            <a href="###" title="1">1</a>
            <a href="###" title="2">2</a>
            <a href="###" title="3">3</a>
            <a href="###" title="4">4</a>
            <a href="###" title="5">5</a>
            <a href="###" title="6">6</a>
            <a href="###" title="7">7</a>
            <a href="###" title="8">8</a>
        </div>
    </div>
</body>
</html>

View Code

#picMain
{
    margin: auto;
    overflow: hidden;
    width: 1000px;
    height: 400px;
    position: relative;
}
#divImg
{
    width: 10000px;
    height: 400px;
    background-color: #000000;
    position: absolute;
    top: 0px;
}
#divLink
{
    position: absolute;
    width: 1000px;
    height: 50px;
    background-color: #000000;
    filter: alpha(opacity=50);
    -moz-opacity: 0.5;
    opacity: 0.5;
    overflow: auto;
    display: block;
    bottom: 0px;
    left: 0px;
}
#divLink a
{
    border: 1px solid #C0C0C0;
    width: 30px;
    height: 30px;
    float: left;
    margin-left: 10px;
    line-height: 30px;
    text-decoration: none;
    text-align: center;
    color: #FFFFFF;
    font-weight: bold;
    margin-top: 10px;
    display: block;
}
#divImg img
{
    width: 1000px;
    height: 400px;
    float: left;
}
.picselect
{
    background-color: #919191;
}

View Code

以上HTML和CSS并不是解决楼主的BUG,只是我在你的基础之上修改了一下,正好自我学习一番。希望你不会介意。

我有几个建议:(1)分号漏了哦  (2)大括号位置不统一  (3)函数名,变量名最好是动宾结构,比如picNext改为nextPic

以上仅是个人观点

坑爹的问题,jquery样式与css样式的神秘问题

相关文章:

你感兴趣的文章:

标签云: