In HTML, the percentage width and position of the box after relative, absolute, and fixed are prone to errors.

Source: Internet
Author: User

In HTML, the percentage width and position of the box after relative, absolute, and fixed are prone to errors.

1. relative Positioning relative: as the name suggests, relative positioning is offset relative to its own position, for example:

Take the center of the box as the benchmark, which is the positive direction of each edge, for example:

Move 20px to the right: the code is left: 20px; or right:-20px;

Move 20px down: the code is top: 20px; or bottom:-20px;

 

2. absolute positioning: absolute

Based on its first ancestor-level box, the center direction of the ancestor-level is positive, for example:

3. fixed positioning fixed, which is independent of the body Tag, is based only on html of the webpage. Its Positioning method is similar to absolute positioning and is in the center direction as the positive direction.

The width percentage is only based on html.

 

Note: 1. If there is no parent-level positioning, absolute positioning of absolute is based on its first positioning ancestor by default.

2. Absolute positioning and relative positioning of the box, the width percentage is based on the first positioning ancestor; the default is based on the body

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.