jQuery 自适应 bxSlider 宽度或中心图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22278650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adaptive bxSlider width or center image
提问by MDTech.us_MAN
I have a slideshow with pictures of many different aspect ratios. I would like the images to be centered in the slideshow. How can I do this, or even better, how can I automatically resize the slider?
我有一个幻灯片,其中包含许多不同纵横比的图片。我希望图像在幻灯片中居中。我怎样才能做到这一点,或者更好的是,我怎样才能自动调整滑块的大小?
回答by newTag
For solving the center problem
为了解决中心问题
.bx-wrapper img {
margin: 0 auto;
}
The width of each slide. This setting is required for all horizontal carousels!
每张幻灯片的宽度。所有水平转盘都需要此设置!
Like this:
像这样:
JS:
JS:
$('.bxslider').bxSlider({
mode: 'fade',
captions: true,
pagerCustom: '#bx-pager',
adaptiveHeight: true,
slideWidth: 300
});
HTML:
HTML:
<ul class="bxslider">
<li><img src="/images/730_200/hill_fence.jpg" /></li>
<li><img src="/images/730_100/tree_root.jpg" /></li>
<li><img src="/images/730_150/me_trees.jpg" /></li>
</ul>