Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the centered layout of css

Shulou Source: shulou.com Published: 2022-06-01 04:58:09 11月12日 Update

This article mainly introduces how to achieve the central layout of css, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

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 can make the width of the element adaptive and does not inherit the width of the parent element. * / margin:0auto;} Thank you for reading this article carefully. I hope the article "how to achieve the central layout of css" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Element width layout article value interest at the same time more friends level knowledge editing industry information information channel channel reference learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi Huawei NVidia macOS