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.
< ;/body>
Statement: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