任何人都知道为什么旋转木马没有水平居中?我使用slick.js
作为轮播。
已将display: table; margin: 0 auto;
设置为水平居中但不起作用。
jsfiddle
.. http://jsfiddle.net/bobbyrne01/4qpejg98/1/
html
..
<div class="centerHorizontally parent">
<div class="halfWidth child">
<div class="slider multiple-items">
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
<div>
<div class="centerHorizontally">
<img src="http://placehold.it/50x50" />
</div>
</div>
</div>
</div>
</div>
css
:
html, body {
height: 100%;
}
.parent {
width: 100%;
height: 100%;
display: table;
text-align: center;
}
.parent > .child {
display: table-cell;
vertical-align: middle;
}
.slider {
width: 50%;
height: 10%;
}
.slick-prev:before, .slick-next:before {
color:#808080;
}
.centerHorizontally {
display: table;
margin: 0 auto;
}
.halfWidth {
width: 50%;
}
javascript
:
$('.multiple-items').slick({
infinite: false,
slidesToShow: 5,
slidesToScroll: 5,
dots: true
});
答案 0 :(得分:2)