简体   繁体   中英

Image in a DIV - vertical centered

i have a DIV with a size x and some images in it with often a larger size. And in this case i need the image vertical centered in this DIV.

Dows anyone know, how i can realize that?

Thanks for reading that!

You can place the images inside divs and place those divs into the Your div and after words to center them

You can also make a class fo those divs and in the css part position:center;

您可以在此处使用垂直对齐方式http://phrogz.net/css/vertical-align/index.html

If the div contains only images and no text/one liner, you can set line-height=height and use vertical-align to center the image.

<div style="height: 10px; line-height: 10px">
    <img src="" style="vertical-align: middle"/> 
</div>

PS: It is important to have a space character after the <img/> to force the image to align to the space in IE6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM