html - How to vertically center and right-align an image? -


i want image on right side of <div> centered vertically.

enter image description here

i flexbox or simple possible.

#container1 {    width: auto;    height: auto;  }  #div1 {    width: 400px;    height: 200px;    border: 1px solid black;    text-align: right;    display: flex;    align-items: center;    justify-content: center;  }  #some_image {    width: 50px;    height: 25px;  }
<div id="container1">    <div id="div1"><img id="some_image" src="some_image.gif"></div>

you close

flexbox solution

#div1 {        width: 400px;        height: 200px;        margin: 1em auto;        border: 1px solid black;        display: flex;        align-items: center;       /* vertical center */        justify-content: flex-end; /* far right */  }    #some_image {       width: 50px;        height: 25px;  }
<div id="div1">    <img id="some_image" src="http://lorempixel.com/image_output/abstract-q-c-50-25-6.jpg">  </div>


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -