Home  >  Article  >  Web Front-end  >  What does float mean in css?

What does float mean in css?

清浅
清浅Original
2019-05-14 11:38:505480browse

float in CSS means floating. When the float attribute is set on an element, it will break away from the standard flow and float on other elements. It will float to the left or right according to the attribute value.

In CSS The float attribute is a frequently used attribute. For beginners, if they do not understand the meaning and characteristics of float, it is easy to get confused and confused when using it. Next, I will introduce this attribute in detail in the article, I hope it will be helpful to everyone.

What does float mean in css?

float attribute

float, as the name suggests, floats. Elements with the float attribute set will move to the left or right according to the attribute value. Floating, we call elements with the float attribute set as floating elements.
After an element uses the float attribute, the element can be separated from the standard flow itself and float on top of other elements so that it no longer occupies the space originally belonging to the element. This will cause the subsequent elements to move up and occupy the space originally belonging to the element. The space for this element.

Example:

                      浮动元素                    普通文档流普通文档流普通文档流普通文档流普通文档流普通文档流普通文档流普通文档流普通文档流普通  文档流普通文档流普通文档流普通文档流普通文档流普通文档流  

Understanding of float attribute

1. The float attribute only affects the element itself and subsequent elements using this attribute. Have an impact (the following elements move up --> the footer block moves up).

2. After the inline element uses the float attribute, it will become a block-level element, and the height and width of the element can be set (refer to the A tag).

3. The float attribute is generally used together with the clear attribute of the following tags to clear the impact of the float attribute on the following elements.

4. For elements using the float attribute, if the element width is not set, the element width is automatically adjusted to fit the width of the content (refer to content DIV--the size of the content block is not defined, so it is automatically adjusted).

The above is the detailed content of What does float mean in css?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:What does position mean?Next article:What does position mean?