Reputation: 6745
Anyone know why carousel is not centering horizontally? I'm using slick.js
for carousel.
Have set display: table; margin: 0 auto;
to center horizontally but its not working.
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
});
Upvotes: 2
Views: 2226
Reputation: 9615
You have to add margin: 0 auto
to .slider
div.
.slider {
margin: 0 auto;
}
Fiddle: http://jsfiddle.net/4qpejg98/2/
Upvotes: 2