Tag: element horizontally vertically centered vertically centered horizontally centered
Known wide height element horizontal vertical centering scheme
Using the absolute genus of the position, the vertical center of the previous article is based on the horizontal center
Code
Index.html
<! DOCTYPE html><html lang="zh"> <head> <meta charset="UTF-8"> <title>Known wide height element horizontally vertically centered</title> <style> #container { position: Absolute ; top: % ;Left : % ; margin-top: -px ; margin-left: -px ; height: px ; width: px ; background: #000 ;} /* First pull the block to 50% of the page, because the top alignment is (50%,50%), so you must pull back half the size of the element to achieve full centering * / </style> </head> <body> <div id="container"></div> </body></html>
The center of the page Elements _ (3) The width of the element is known horizontally vertical center