如何调整jquery.simply-scroll插件的CSS设置以占据全屏

时间:2014-04-27 07:59:11

标签: php jquery html css simplyscroll

我正在尝试使用jquery简单地滚动插件t animate循环无限滚动。我的Html概述如下:

<html>
<head>
<!- title,link,script tags go here... -->
</head>

<body>
<div id="holder" style="position : relative;">
  <div id="slider" style="position : fixed; overflow : hidden; z-index : -1;">
    <ul id="scroller">
      <li><img src="img/1.jpg" /></li>
      <li><img src="img/2.jpg" /></li>
      <li><img src="img/3.jpg" /></li>
      <li><img src="ing/4.jpg" /></li>
    </ul>
  </div>
  <div id="main" style="position : absolute"><!- Holds the page r site contenys --></div>
</div>
</body>

</html>

默认的jquery.simply-scroll.css(未经编辑)提供简单的滚动插件zip存档如下:

/*
 * simplyScroll 2 - a scroll-tastic jQuery plugin
 *
 * http://logicbox.net/jquery/simplyscroll
 *
 * Copyright (c) 2009-2012 Will Kelly - http://logicbox.net
 *
 * Dual licensed under the MIT and GPL licenses.
 *
 * Last revised: 31/01/2012
 *
 */

/* Default/Master classes 

Example markup format (for horizontal scroller)
Note all DIVs are generated and should not be hard-coded

<div class="your-custom-class simply-scroll-container">
    <div class="simply-scroll-btn simply-scroll-btn-left"></div>
    <div class="simply-scroll-btn simply-scroll-btn-right"></div>
    <div class="simply-scroll-clip">
        <ul class="simply-scroll-list">
            <li>...</li>
            ...
        </ul>
    </div>
</div>


*/

.simply-scroll-container { /* Container DIV - automatically generated */
    position: relative;
}

    .simply-scroll-clip { /* Clip DIV - automatically generated */
        position: relative;
        overflow: hidden;
    }

    .simply-scroll-list { /* UL/OL/DIV - the element that simplyScroll is inited on */
        overflow: hidden;
        margin: 0;
        padding: 0;
        list-style: none;
    }

        .simply-scroll-list li {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        .simply-scroll-list li img {
            border: none;
            display: block;
        }

    .simply-scroll-btn {
        position: absolute;
        background-image: url(buttons.png);
        width: 42px;
        height: 44px;
        z-index:3;
        cursor: pointer;
    }

    .simply-scroll-btn-left {
        left: 6px;
        bottom: 6px;
        background-position: 0 -44px;
    }
    .simply-scroll-btn-left.disabled {
        background-position: 0 0 !important;
    }
    .simply-scroll-btn-left:hover, .simply-scroll-btn-left:focus {
        background-position: 0 -88px;
    }

    .simply-scroll-btn-right {
        right: 6px;
        bottom: 6px;
        background-position: -84px -44px;
    }
    .simply-scroll-btn-right.disabled {
        background-position: -84px 0 !important;
    }
    .simply-scroll-btn-right:hover, .simply-scroll-btn-right:focus {
        background-position: -84px -88px;
    }

    .simply-scroll-btn-up {
        right: 6px;
        top: 6px;
        background-position: -126px -44px;
    }
    .simply-scroll-btn-up.disabled {
        background-position: -126px 0 !important;
    }
    .simply-scroll-btn-up:hover, .simply-scroll-btn-up:focus {
        background-position: -126px -88px;
    }

    .simply-scroll-btn-down {
        right: 6px;
        bottom: 6px;
        background-position: -42px -44px;
    }
    .simply-scroll-btn-down.disabled {
        background-position: -42px 0 !important;
    }
    .simply-scroll-btn-down:hover, .simply-scroll-btn-down:focus {
        background-position: -42px -88px;
    }

    .simply-scroll-btn-pause {
        right: 6px;
        bottom: 6px;
        background-position: -168px -44px;
    }
    .simply-scroll-btn-pause:hover, .simply-scroll-btn-pause:focus {
        background-position: -168px -88px;
    }

    .simply-scroll-btn-pause.active {
        background-position: -84px -44px;
    }
    .simply-scroll-btn-pause.active:hover, .simply-scroll-btn-pause.active:focus {
        background-position: -84px -88px;
    }

    /* Custom class modifications - override classees

    .simply-scroll is default

    */

    .simply-scroll { /* Customisable base class for style override DIV */
        width: 576px;
        height: 200px;
        margin-bottom: 1em;
    }

        .simply-scroll .simply-scroll-clip {
            width: 576px;
            height: 200px;
        }

            .simply-scroll .simply-scroll-list {}

            .simply-scroll .simply-scroll-list li {
                float: left;
                width: 290px;
                height: 200px;
            }
            .simply-scroll .simply-scroll-list li img {}

        .simply-scroll .simply-scroll-btn {}

        .simply-scroll .simply-scroll-btn-left {}
        .simply-scroll .simply-scroll-btn-left.disabled {}
        .simply-scroll .simply-scroll-btn-left:hover {}

        .simply-scroll .simply-scroll-btn-right {}
        .simply-scroll .simply-scroll-btn-right.disabled {}
        .simply-scroll .simply-scroll-btn-right:hover {}

        .simply-scroll .simply-scroll-btn-up {}
        .simply-scroll .simply-scroll-btn-up.disabled {}
        .simply-scroll .simply-scroll-btn-up:hover {}

        .simply-scroll .simply-scroll-btn-down {}
        .simply-scroll .simply-scroll-btn-down.disabled {}
        .simply-scroll .simply-scroll-btn-down:hover {}



    /* Vertical scroller example */

    .vert { /* wider than clip to position buttons to side */
        width: 340px;
        height: 400px;
        margin-bottom: 1.5em;
    }

        .vert .simply-scroll-clip {
            width: 290px;
            height: 400px;
        }

            .vert .simply-scroll-list {}

            .vert .simply-scroll-list li {
                width: 290px;
                height: 200px;
            }
            .vert .simply-scroll-list li img {}

        .vert .simply-scroll-btn {}

        .vert .simply-scroll-btn-up { /* modified btn pos */
            right: 0;
            top: 0;
        }
        .vert .simply-scroll-btn-up.disabled {}
        .vert .simply-scroll-btn-up:hover {}

        .vert .simply-scroll-btn-down { /* modified btn pos */
            right: 0;
            top: 52px;
        }
        .vert .simply-scroll-btn-down.disabled {}
        .vert .simply-scroll-btn-down:hover {}

        /* NOTE left-right classes wouldn't be needed on vertical scroller */

当链接到HTML时,上面的css在所有浏览器中都是相同的。滚动效果覆盖背景左上角的570x200px。但是,当我尝试自定义它以占据整个屏幕时,它会出现意外行为,即它在IE10&amp; Firefox但在Chrome中没有。上述CSS的自定义版本如下:

/*
 * simplyScroll 2 - a scroll-tastic jQuery plugin
 *
 * http://logicbox.net/jquery/simplyscroll
 *
 * Copyright (c) 2009-2012 Will Kelly - http://logicbox.net
 *
 * Dual licensed under the MIT and GPL licenses.
 *
 * Last revised: 31/01/2012
 *
 */

/* Default/Master classes 

Example markup format (for horizontal scroller)
Note all DIVs are generated and should not be hard-coded

<div class="your-custom-class simply-scroll-container">
    <div class="simply-scroll-btn simply-scroll-btn-left"></div>
    <div class="simply-scroll-btn simply-scroll-btn-right"></div>
    <div class="simply-scroll-clip">
        <ul class="simply-scroll-list">
            <li>...</li>
            ...
        </ul>
    </div>
</div>


*/

.simply-scroll-container { /* Container DIV - automatically generated */
    position: relative;
}

    .simply-scroll-clip { /* Clip DIV - automatically generated */
        position: relative;
        overflow: hidden;
    }

    .simply-scroll-list { /* UL/OL/DIV - the element that simplyScroll is inited on */
        overflow: hidden;
        margin: 0px;
        padding: 0px;
        list-style: none;
    }

        .simply-scroll-list li {
            padding: 0px;
            margin: 0px;
            list-style: none;
        }

        .simply-scroll-list li img {
            border: none;
            display: block;
        }

    .simply-scroll-btn {
        position: absolute;
        background: url('../img/buttons/buttons.png');
        width: 42px;
        height: 44px;
        z-index:3;
        cursor: pointer;
    }

    .simply-scroll-btn-left {
        left: 6px;
        bottom: 6px;
        background-position: 0 -44px;
    }
    .simply-scroll-btn-left.disabled {
        background-position: 0 0 !important;
    }
    .simply-scroll-btn-left:hover, .simply-scroll-btn-left:focus {
        background-position: 0 -88px;
    }

    .simply-scroll-btn-right {
        right: 6px;
        bottom: 6px;
        background-position: -84px -44px;
    }
    .simply-scroll-btn-right.disabled {
        background-position: -84px 0 !important;
    }
    .simply-scroll-btn-right:hover, .simply-scroll-btn-right:focus {
        background-position: -84px -88px;
    }

    .simply-scroll-btn-up {
        right: 6px;
        top: 6px;
        background-position: -126px -44px;
    }
    .simply-scroll-btn-up.disabled {
        background-position: -126px 0 !important;
    }
    .simply-scroll-btn-up:hover, .simply-scroll-btn-up:focus {
        background-position: -126px -88px;
    }

    .simply-scroll-btn-down {
        right: 6px;
        bottom: 6px;
        background-position: -42px -44px;
    }
    .simply-scroll-btn-down.disabled {
        background-position: -42px 0 !important;
    }
    .simply-scroll-btn-down:hover, .simply-scroll-btn-down:focus {
        background-position: -42px -88px;
    }

    .simply-scroll-btn-pause {
        right: 6px;
        bottom: 6px;
        background-position: -168px -44px;
    }
    .simply-scroll-btn-pause:hover, .simply-scroll-btn-pause:focus {
        background-position: -168px -88px;
    }

    .simply-scroll-btn-pause.active {
        background-position: -84px -44px;
    }
    .simply-scroll-btn-pause.active:hover, .simply-scroll-btn-pause.active:focus {
        background-position: -84px -88px;
    }

/* Custom class modifications - override classees

.simply-scroll is default

*/

.simply-scroll { /* Customisable base class for style override DIV */
    width: inherit;
    height: inherit;
    margin: 0;
}

    .simply-scroll .simply-scroll-clip {
        width: inherit;
        height: inherit;
    }

        .simply-scroll .simply-scroll-list {}

        .simply-scroll .simply-scroll-list li {
            float: left;
/*          height:100%;
            width: auto;
            background: yellow;
*/      }
        .simply-scroll .simply-scroll-list li img {
            height: 100%;
            width: auto;
        }

    .simply-scroll .simply-scroll-btn {}

    .simply-scroll .simply-scroll-btn-left {}
    .simply-scroll .simply-scroll-btn-left.disabled {}
    .simply-scroll .simply-scroll-btn-left:hover {}

    .simply-scroll .simply-scroll-btn-right {}
    .simply-scroll .simply-scroll-btn-right.disabled {}
    .simply-scroll .simply-scroll-btn-right:hover {}

    .simply-scroll .simply-scroll-btn-up {}
    .simply-scroll .simply-scroll-btn-up.disabled {}
    .simply-scroll .simply-scroll-btn-up:hover {}

    .simply-scroll .simply-scroll-btn-down {}
    .simply-scroll .simply-scroll-btn-down.disabled {}
    .simply-scroll .simply-scroll-btn-down:hover {}

请指出问题&amp;同样的解决方案。我设计的链接如下:

 - http://appspot.comyr.com/restaurants_hd/      main site
 - http://appspot.comyr.com/restaurants_hd/js/  Js files
 - http://appspot.comyr.com/restaurants_hd/css/ css files
 - http://appspot.comyr.com/restaurants_hd/img/ image files

尝试在IE,Firefox,Chrome中找到主站点的链接,你可以注意到这个问题。即使在某些情况下,如果4张图像仅显示1张或有时2张图像,其余图像也会消失,则滚动可以正常工作。

请使用正确的设置帮助我,以便滚动填满整个屏幕(无论屏幕分辨率如何)。

谢谢&amp;问候。

1 个答案:

答案 0 :(得分:1)

Go through below jsfiddle.

http://jsfiddle.net/uruwf/3/

希望它会对你有帮助。

我已经在IE-9及以上版本中测试过它,Google Chrome最新版本和firefox-31.0版本。它的工作性很好。