Master CSS Advanced Web Standard Solution-visual format model-positioning model

Source: Internet
Author: User

There are three kinds of positioning mechanisms in CSS: normal flow, floating, absolute positioning. (default to normal stream)

Change document flow: Display:inline-block; (Support to IE8 and above)

1-Anonymous block box:

    < Div >             Hi there!             < P > Lio Ali! </ P >        </ Div >

This piece of "Hello", belongs to the anonymous block box because it is not associated with a specially defined element.

2-relative positioning

The relative positioning of an element is positioned relative to its original position.

<!DOCTYPE HTML><HTML>    <Head>        <title>CSS Bug test</title>        <MetaCharSet= "Utf-8">        <styletype= "Text/css">. Box-left{Display:Inline-block;width:50px;Height:50px;Background-color:Red;            }. Box-middle{position:relative;Top:10px; Left:20px;Display:Inline-block;width:50px;Height:50px;Background-color:Green;            }. Box-right{Display:Inline-block;width:50px;Height:50px;Background-color:Pink;            }        </style>    </Head>    <Body>        <Divclass= "Box-left"></Div>        <Divclass= "Box-middle"></Div>        <Divclass= "Box-right"></Div>            </Body></HTML>

When the element is positioned relatively, it will occupy its original position regardless of whether it has a top and left value set, or whether it is moving or not, and may overwrite other elements after moving.

3-Absolute positioning

Concept: Unlike relative positioning, the position of absolute positioning is independent of the document flow and therefore does not occupy space. Other elements in the normal document stream are not present.

Test: The code as shown on the relative positioning code, the only difference is to put position:relative; Replaced by Position:absolute;

Relative positioning Absolute positioning
. box-middle{                position:relative;                top:10px;                left:20px;                Display:inline-block;                width:50px;                height:50px;                Background-color:green;            }

. box-middle{                Position:absolute;                top:20px;                left:20px;                Display:inline-block;                width:50px;                height:50px;                Background-color:green;            }

4-Fixed positioning

Support to IE7 above, 7 part support

5-Floating

Master CSS Advanced Web Standard Solution-visual format model-positioning model

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.