2
我使用的宽度设置为100%的anythingslider,以便它填充页面,并且除了当页面使用滚动条,滑块是滚动条的100%宽度时,它工作正常。 我能做些什么来解决这个问题吗?AnythingSlider宽度与页面滚动故障?
我使用的宽度设置为100%的anythingslider,以便它填充页面,并且除了当页面使用滚动条,滑块是滚动条的100%宽度时,它工作正常。 我能做些什么来解决这个问题吗?AnythingSlider宽度与页面滚动故障?
代替滑块的宽度设定为100%的。让其父为100%(还设置了高度),然后设置expand
选项true
(demo):
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
});
尝试:
var width = document.body.clientWidth; // this is the inner or viewport dimension that excludes scrollbars
$("#slider").width(width);