Question about vertical center of div due to error 12306 _ html/css_WEB-ITnose

Source: Internet
Author: User
Due to the vertical center problem of div due to 12306 errors, I want to see if there are still no remaining tickets when I go home on New Year's Day. I opened 12306 secretly and started to query the tickets for returning home. I found that I could not query them, an error occurred while checking again.

Seeing this is very depressing and tangled, But I suddenly thought that I had been trying to center p vertically recently. I tried a website as large as 12306 and it must be vertically centered,

After a try, I was not disappointed and adapted to the vertical center of various resolutions.

Great. Right-click the source code.

P class = "err_text">
 
 
  • Network problems may exist. Please try again!

Then let's take a look at how css is written.

.err_text{    position:absolute;    margin-top:-159px;        top:50%;    left:50%;    margin-left:-247px;    width:495px;    height:282px;}#error{    width:495px;    margin-left:auto;    margin-right:auto;    list-style:none;}#error li{    list-style:none;}#err_top{    background:url(err_top.gif) no-repeat;    height:78px;    line-height:78px;    width:495px;    }#err_bot{    background:url(err_bot.gif) no-repeat;    height:204px;    padding-top:50px;    width:495px;        text-align:center;    font-size:14px;    font-weight:bold;}

At this time, you will surely find that the key code is actually top: 50%, left: 50%. Of course, the premise is absolute positioning, so that you can center it.

Related Article

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.