Unknown Size Image vertical and horizontal center problem in container _ CSS/HTML
Source: Internet
Author: User
An unknown size image is in the CSS layout of the vertical and horizontal center of the container. Vertical center of an unknown size image has always been a headache, the standard browser only needs to set the line-height of the container and the vertical-align: middle; of the image, but it is useless to IE, I saw a solution to Internet Explorer on a foreign website a few months ago. I don't feel very good, and I didn't take it seriously. Recently, I have seen some friends asking similar questions, turning out the code and changing the code for IE.
. Box [class] {
Font-size: 12px;/* this value is required by the standard browser */
}
Img {
Vertical-align: middle;/* vertical center of standard browser images */
}
The font-size of the original foreigner code is the same as the height. After the test, the height of the container is higher than that of the standard browser, and the font size is reduced by 10 percent of the height of the container multiple times, in this way, it looks similar. The reason is unclear.
The test is successful in IE5.5, IE6.0, FF1.5, and Opera9.0, and is invalid for IE5.0 and IE7.0.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.