A brief introduction to floating properties in CSS

黄舟
Release: 2017-06-04 11:51:03
Original
2199 people have browsed it

To introduce the floatfloating attribute of css, you must first understand the standard document flow

Standard document flow:

Without the intervention of CSS, block-level elements occupy one line alone. The width and height can be set. Inline elements are displayed side by side, and the width and height are automatically filled.

The standard document flow (default layout) of an HTML page is: from top to bottom, from left to right, with line breaks when encountering blocks (block-level elements).

The initial use of the float attribute was to wrap the target content in text, which is often seen in newspapers. Later, it was mostly used to realize the horizontal arrangement of content side by side. ,

Floating layer: After assigning a value to the float attribute of the element, it is separated from the document flow and floats left and right, close to the left and right borders of the parent element (default is the body text area).

float attribute introduction:

left: The element floats to the left.

#right: The element floats to the right.

Characteristics of floating:

[1] The floating child level causes the height of the parent level to collapse. Solution: 1. Add the parent level again A height 2. Use overflow: hidden

【2】Floating wrapping:

block Level element: is wrapped into the content area and no longer occupies a whole line, but it still has the same length as the content, and the body is still a block-level element;

Inline element: After setting the float, the display attribute will be changed, making it a block-level element, and the width and height can be set.

【3】Floating elements will not pass through the padding area

【4】Floating elements will leave the document Flow affects other elements.

The above is the detailed content of A brief introduction to floating properties in CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template