Insert the coordinate div to center, and the coordinate div to center

Source: Internet
Author: User

Insert the coordinate div to center, and the coordinate div to center

<! Doctype html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Meta name = "Author" content = "Hu Chao">
<Title> super Hu </title>
<Style type = "text/css">
Html, body, div {margin: 0; padding: 0}/*, insert a div outside the content Element
And set the div height: 50%; margin-bottom:-(contentheight + padding)/2 ;.

For example, if the content height is 100px and the total padding is 20px, margin-bottom:-60px will squeeze the content down.
The disadvantage is to add meaningless labels, but the advantage is that IE6 is simple and compatible */
. Box {
Margin: 20px auto;
Width: 200px;
Height: 600px;
Background: black;
}
. Floater {
Height: 50%;
Margin-bottom:-50px;
}
. Content {

Margin: 0 auto;
Padding: 10px;
Width: 100px;
Height: 100px;
Border: 2px solid # adf;
Background: # abc;
}

</Style>

</Head>
<Body>
<Div class = "box">
<Div class = "floater"> </div>
<Div class = "content"> </div>
</Div>
</Body>
</Html>

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.