CSS authoritative guide-floating and positioning

Source: Internet
Author: User

Positioning

The idea of positioning is very simple where the element box appears relative to the normal position.

Positioning: Static, relative, absolute, fixed, inherited

Static is the default location

Relative is the offset from the default position. The original static positioning position still occupies.

Absolute positioning is relative to the offset of the containing block (not static). Completely out of the document flow, the original location is gone.

Fix offset relative to the viewport window.

Include Block

The root element is the initial containing block, some browsers are HTML elements, and some are body.

Non-root element, position is a relative or default location, and contains blocks that are recent ancestor-level block-level boxes, table cells, inline blocks.

Non-root, position is absolute, contains the block as the nearest non-static ancestor element.

If it is a block level, the bounds of the containing block are the inner boundaries of the containing block.

If it is within a row, the containing block is the boundary of the row box.

If there is no ancestor, the containing block is the initial containing block.

The inclusion block (containing box) is actually the positioning context. It is understood as a reference environment for position positioning.

Offset property

With reference to the environment, on the two-dimensional, the upper and lower left and right offset how much?

The value of this property can be a length, percent, auto, inherit

The value can be negative, or offset in the opposite direction.

The length is well understood, and the percentage is the percentage of the value that contains the block. For example, Top/bottom 10% is 10 of the height of the block, if Left/right is the width.

Found a problem if an element that is positioned as relative contains a block height that is not set, it should be auto. Top/bottom is set to a value of percent. The browser (firefox38) ignores this percentage value.

Reference:

Last Comment Bug 260348 -Relative positioning with percentages inside auto-height containing block does Not work

https://bugzilla.mozilla.org/show_bug.cgi?id=260348

CSS authoritative guide-floating and positioning

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.