Sharing common skills of css page layout
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!