vendredi 27 mars 2015

How can I center an image that is in a div with a dynamic height?

I have a div that is 1/5 the vh of the screen. I want the image within that div to be centered vertically. I am able to center it horizontally but have tried the following code thus far:


http://ift.tt/1EJ5Nv3





img{
width:25px;
}

.container-fluid > div{
text-align:center;
height: calc(100vh/5);
}

.container-fluid > div:nth-child(odd){
background:yellow;
}



<div class="container-fluid">
<div><img src="http://ift.tt/1EJ5PmC"></div>
<div><img src="http://ift.tt/1EJ5PmC"></div>
<div><img src="http://ift.tt/1EJ5PmC"></div>
<div><img src="http://ift.tt/1EJ5PmC"></div>
<div><img src="http://ift.tt/1EJ5PmC"></div>
</div>



Aucun commentaire:

Enregistrer un commentaire