Center big image in smaller div
Posted
by
larin555
on Stack Overflow
See other posts from Stack Overflow
or by larin555
Published on 2012-11-18T22:57:11Z
Indexed on
2012/11/18
22:59 UTC
Read the original article
Hit count: 231
css
I'm trying to align images in the center of a slider div. I'm adjusting FlexSlider css by the way. Here's my CSS code :
.flexslider {margin: 0; padding: 0; width: 600px; height:480px; overflow:hidden;margin-left:auto;margin-right:auto;}
.flexslider .slides > li {display: none; -webkit-backface-visibility: hidden;} /* Hide the slides before the JS is loaded. Avoids image jumping */
.flexslider .slides img {width:auto;height:100%; display: inline-block; text-align:center;}
Everything is working like I want, except that I want wider image to be centered in the div. Right now it is left-aligned. I cannot use background-image by the way. Any ideas?
I also tried applying to the .flexslider .slides img :
margin-left:-50%
...not working
margin-left:auto
and margin-right:auto
...not working
left:50%
and right:50%
...not working either
© Stack Overflow or respective owner