AnythingSlider宽度与页面滚动条毛刺?

时间:2012-04-24 11:39:45

标签: jquery anythingslider

我正在使用宽度设置为100%的anythingslider,以便它填充页面,并且它工作正常,除非页面使用滚动条,然后滑块是滚动条的100%+宽度。 我有什么办法可以解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

试试这个:

 var width = document.body.clientWidth; // this is the inner or viewport dimension that excludes scrollbars 
 $("#slider").width(width);

答案 1 :(得分:1)

而不是将滑块的宽度设置为100%。将其父级设为100%(也设置高度),然后将expand选项设置为truedemo):

HTML

<div id="wrapper">
    <ul id="slider">
        <li><img src="http://placekitten.com/300/200" alt="" /></li>
        <li><img src="http://placehold.it/300x200" alt="" /></li>
        <li><img src="http://ipsumimage.appspot.com/300x200.png" alt="" /></li>
        <li><img src="http://dummyimage.com/300x200/000/fff.jpg" alt="" /></li>
    </ul>
</div>

CSS

#wrapper {
    height: 500px;
}

脚本

$('#slider').anythingSlider({
    // If true, the entire slider will expand to fit the parent element
    expand: true
});​