The center of the page Elements _ (3) The width of the element is known horizontally vertical center

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.