You must not know how the pictures in the div are centered horizontally and vertically

You must not know how the pictures in the div are centered horizontally and vertically

You must not know how the pictures in the div are centered horizontally and vertically. Here, the editor provides five centering methods. Let’s take a look. body structure Method 1:Set display to table-cell, then set text-align to center for horizontal centering, and set vertical-align to middle for vertical centering. The result is shown in the figure below:It is realized by position positioning. Set p to relative positioning, and set img to absolute positioning, left: 50%, top: 50%. At this time, the upper left corner of the picture is at the center of p. If the center of the picture is at the center of p, You need to move the image up by half the image height and to the left by half the image width. The result is shown in the figure below:It is still achieved through position positioning. Set p to relative positioning, and set img to absolute positioning, left: 50%, top: 50%. At this time, the upper left corner of the picture is at the center of p. If the center of the picture is at the center of p, you need to place the picture Move half the height of the picture up and half the…

You must not know how the pictures in the div are centered horizontally and vertically

You must not know how the pictures in the div are centered horizontally and vertically

You must not know how the pictures in the div are centered horizontally and vertically. Here, the editor provides five centering methods. Let’s take a look. body structure Method 1:Set display to table-cell, then set text-align to center for horizontal centering, and set vertical-align to middle for vertical centering. The result is shown in the figure below:It is realized by position positioning. Set p to relative positioning, and set img to absolute positioning, left: 50%, top: 50%. At this time, the upper left corner of the picture is at the center of p. If the center of the picture is at the center of p, You need to move the image up by half the image height and to the left by half the image width. The result is shown in the figure below:It is still achieved through position positioning. Set p to relative positioning, and set img to absolute positioning, left: 50%, top: 50%. At this time, the upper left corner of the picture is at the center of p. If the center of the picture is at the center of p, you need to place the picture Move half the height of the picture up and half the…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索