How does css implement vertical and horizontal center of images in an unknown wide-height div? cssdiv
How does css implement vertical horizontal center of images in an unknown wide-height div:
In some cases, we may want to align an image vertically and horizontally in the div, but sometimes the size of the div is the position, the following code describes how to implement vertical and horizontal center of an image in this case.
The Code is as follows:
Instance 1:
<! DOCTYPE html>
The above Code allows the image to be vertically and horizontally centered. Of course, the div size is fixed here, just for demonstration purposes. The unknown size can also be vertically and horizontally centered, the key code is as follows:
Display: table-cell; vertical-align: middle;
Some compatibility issues exist in the Code. Of course, this is not a problem because IE7 and IE6 browsers will soon be eliminated.
The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 14774.
For more information, see: http://www.softwhy.com/divcss/