Get the App
SLTechnology News&Howtos  ›  Development  › 

Sharing common skills of css page layout

Shulou Source: shulou.com Published: 2022-06-03 17:53:22 09月16日 Update

This article mainly explains the "sharing of common skills in css page layout". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "sharing common skills in css page layout".

Css centered layout

Central layout

Centered horizontally (width adaptive)

1.inline-block+text-align

.child {

Display:inline-block;/* becomes an inline block element, making the element width adaptive and does not inherit the parent element width; * /

}

.parent {

Text-align:center

}

2.table+margin

.child {

Display:table;/* becomes a table element, which makes the width of the element adaptive and does not inherit the width of the parent element; * /

Margin:0auto

}

Css multi-column layout

Left

Right

Right

Fixed width on the left, adaptive on the right

Float+margin

.left {

Width:100px

Float:left

}

.right {

Margin-left:120px

}

Float+overflow

/ * the effect is the same as that of method 1 * /

.left {

Width:100px

Float:left

}

.right {

Margin-left:20px

Overflow:hidden

}

Table

.parent {

Display:table

Width:100%

Table-layout:fixed

}

.left, .right {

Display:table-cell

}

.left {

Width:100px

Padding-right:20px

}

Thank you for your reading, the above is the content of "sharing common skills of css page layout". After the study of this article, I believe you have a deeper understanding of the sharing of common skills in css page layout, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Layout elements width common use skills pages learning content right that is ideas situations effects articles methods more levels knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology Xiaomi Huawei Microsoft