Home > Web Front-end > HTML Tutorial > css style for vertically centering images in div layers_html/css_WEB-ITnose

css style for vertically centering images in div layers_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:27:54
Original
1256 people have browsed it

1. Image definition size
.div{ border:1px solid #000;width:200px;
height:200px;position:relative;
}
. img {
position:absolute;
top:50%;
left:50%;
margin:-50px 0 0 -50px;
width:100px;
height:100px ;
border:1px solid red;
}







2. The image has no defined size   "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Use positioning to display vertical images






In a container with fixed height and width, the image is centered vertically.



Logo




  Logo




Google

< ;/body>




source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template