Absolute positioning Position:absolute, relative positioning position:relative

Source: Internet
Author: User

"1"

When we want to use absolute positioning, there must be two conditions
1 "The parent element must be positioned with the attribute, it is generally recommended to use position:relative (that is, to set the parent element relative positioning);
2 "to the child elements, plus absolute positioning position:absolute (to the child element is set to absolute positioning); Simultaneous plus direction attribute (top, Left,rigth,bottom)

Absolute positioning is the positioning of the parent element as a datum point (if he does not have a parent element, or if its parent element does not have the Position:relative property set) it will be positioned as a datum point for <body>. Absolute positioning is out of the document flow (ie: he floats, no longer occupies the original position)

Absolute Positioning

<! DOCTYPE html>

2 To add absolute positioning to the child elements, not to add relative positioning to the parent element, then the absolute positioning of the child element is the body as a benchmark for positioning

<! DOCTYPE html>


3 Finally, to add relative positioning to the parent element, to add absolute positioning to the child elements, then the absolute positioning of the child element is the parent element as the benchmark to locate the "

<! DOCTYPE html>

Absolute positioning Position:absolute, relative positioning position:relative

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.