Home > Web Front-end > JS Tutorial > body text

Css float box model position

php中世界最好的语言
Release: 2018-03-19 11:54:20
Original
2442 people have browsed it

This time I will bring you the box model of Css floatposition. What are the notes of using the box model position of Css float? Here is a practical case. Let’s take a look. .

Attributes:

float Float

The floating content is wrapped in p, and the width and height are set to p

 clear Clear float.

box-sizing

 Box model in standard mode content-box: (Default attribute)

Padding and border are not included in the defined width and height. The actual width of the object is equal to the sum of the set width value, border, and padding, that is (Element width = width + border + padding)

Box model in weird mode border-box:

padding and border are included within the defined width and height. The actual width of the object is equal to the set width value. Even if border and padding are defined, the actual width of the object will not be changed, that is (Element width = width)

Other properties:

 line-height Line height, used within one line.

Overflow: hidden The excess part is hidden.

Display: block inline inline-block (This element will be replaced by block element, row element, inline block element)

z-index: cascading order. The larger numbers are at the top

Other knowledge points:

Compatibility: Set the width and height of the outermost label, and set the percentage inside.

Box model: from inside to outside, it is content (html), padding, border, and margin.

Positioning:

position:

fix Absolute positioning (relative window positioning)

relative relative positioning has its own position for fine-tuning (occupies the position before fine-tuning)

absolute absolute positioning (The highest position relative to the nearest parent tag with position is body)

<head><style>#a{
    width:400px;
    height:200px;
    border:1px solid red;
    position:relative;
    }
    #b{
        width:100px;
        height:50px;
        border:1px solid green;
        position:absolute;
        bottom:0;
        right:0;
        }
    #c{
        width:100px;
        height:50px;
        background:green;
        position:relative;
        top:280px;
        left:210px;
        z-index:1;
        }#z{
    width:400px;
    height:200px;
    border:1px solid red;
    margin-top:5px;
    }
    #x{
        width:100px;
        height:50px;
        background:red;
        position:absolute;
        top:280px;
        left:140px;
        }
    #y{
        width:100px;
        height:50px;
        border:1px solid green;
        position:relative;
        top:110px;
        left:430px;
        }</style></head><body><!--a边框--><p id="a">
    a    <p id="b">b</p>
    <p id="c">c</p></p><!--z边框--><p id="z">
    z    <p id="x">x</p>
    <p id="y">y</p></p></body>
Copy after login

Collapse and position

Achieve effect

    


I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to php Chinese website Other related articles!

Recommended reading:

Using flex layout

##What are the specifications for front-end single coding

There are several ways to clear the impact of floating on the page

The above is the detailed content of Css float box model position. 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