Use div to control the center display of the img image in the div. As shown below, the yellow area is a 1920*300 image. If the resolution exceeds 1920, it will be fully displayed in the center. If the resolution is 1440, it will display the green color in the yellow image. The area size is displayed in the center. If the resolution is 1024, the yellow image will be displayed as large as the pink area in the center.
The code format should be
<div><img src="http://avatar.csdn.net/B/5/B/1_z549903832.jpg"/></div><style> div{width:50px;height:200px;background:red;position:relative;overflow:hidden;} img{margin:-50px 0px 0px -50px/*img宽度高度的一半*/;top:50%;left:50%;position:absolute;}</style>
The code format should be
, do not set a background image for the div Yes, compatible with IE Google Chrome