下面的代码在 FF、CH 等中运行良好,但在 IE 中没有居中。它朝向屏幕的右侧。
知道为什么吗?
<html>
    <head>
        <title>Sliding DIVs</title>
        <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
        <style>
            * {
                margin:0px;
                padding:0px;
                font-family:arial;
                font-size:12px;
            }
            #cover {
                width:100%;
                height:400px;
                background:#EEEEEE;
                text-align:center;
            }
            #slides {
                width:1024px;
                height:400px;
                margin:0px auto;
            }
            .slide {
                width:1024px;
                height:400px;
                display:none;
                position:absolute;
                border:1px solid #000000;
            }
            .slide img {
                width:1024px;
                height:400px;
            }
            .first {
                display:block;
            }
        </style>
        <script type="text/javascript">
            $(document).ready(function()
            {
                var timeoutId;                                                              //To store timeout id
                var slideImage = function(step)
                {
                    if (step == undefined) step = 1;                                        //If undefined then set default value
                    clearTimeout(timeoutId);                                                //Clear timeout if any
                    var indx = $('.slide:visible').index('.slide');                         //Get current image's index
                    if (step != 0)                                                          //If step == 0, we don't need to do any fadein our fadeout
                    {
                        $('.slide:visible').fadeOut();                                      //Fadeout this slide
                    }
                    indx = indx + step;                                                     //Increment for next slide
                    if (indx >= $('.slide').length)                                         //Check bounds for next slide
                    {
                        indx = 0;
                    }
                    else if (indx < 0)
                    {
                        indx = $('.slide').length - 1;
                    }
                    if (step != 0)                                                          //If step == 0, we don't need to do any fadein our fadeout
                    {
                        $('.slide:eq(' + indx + ')').fadeIn();                              //Fadein next slide
                    }
                    timeoutId = setTimeout(slideImage, 2000);                               //Set Itmeout
                };
                slideImage(0);                                                              //Start sliding
                $('#prev').click(function()                                                 //When clicked on prev
                {
                    slideImage(-1);                                                         //SlideImage with step = -1
                });
                $('#next').click(function()                                                 //When clicked on next
                {
                    slideImage(1);                                                          //SlideImage with step = 1
                });
                $('#stop').click(function()                                                 //When clicked on Pause
                {
                    clearTimeout(timeoutId);                                                //Clear timeout
                    $(this).hide();                                                         //Hide Pause and show Play
                    $('#play').show();
                });
                $('#play').click(function()                                                 //When clicked on Play
                {
                    slideImage(0);                                                          //Start slide image
                    $(this).hide();                                                         //Hide Play and show Pause
                    $('#stop').show();    
                });
            });
        </script>
    </head>
    <body>
        <div id="cover">
            <div id="slides">
                <div class="slide first">1</div>
                <div class="slide">2</div>
                <div class="slide">3</div>
                <div class="slide">4</div>
            </div>
        </div>
    </body>
</html>