How does css align div horizontally and vertically in full screen mode?
How does css align div horizontally and vertically in full screen mode:
This topic describes how to align a div element horizontally and vertically throughout the web page. The Code is the most convincing and you can directly look at the code.
The Code is as follows:
<! DOCTYPE html>
The above code centers the div in full screen on the webpage. The following describes how to implement it.
I. Implementation principle:
Set the div element to absolute positioning, and set its left and right attribute values to 50% respectively. At this time, the div is not centered, and the center is the upper left corner of the div, therefore, we need to pull a certain distance from the top to the left, which is half of the height and width respectively.
Ii. Related reading:
1. Absolute positioning of CSS.
2. For details about negative margin values, refer to the margin-right attribute section of CSS.
The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 14084.
For more information, see: http://www.softwhy.com/divcss/