Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the three-column layout of CSS

Shulou Source: shulou.com Published: 2022-06-01 12:53:51 09月25日 Update

This article mainly shows you the "CSS three-column layout how to achieve", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve the three-column layout of CSS" this article.

The principle of implementation:

The middle column is adaptive, and if we set all three parts to float to the left, then left and right will be squeezed into the next line, so we need to solve this problem. We set the margin-left of both left and right to negative values, and set the padding-left and padding-right of the parent element to make room for the left and right columns. Finally, you need to set the left and right settings to position them, and set their left and right properties.

The specific code is as follows:

CSS implements a three-column layout-(yisu.com) # main {padding-left: 220px; padding-right: 220px;} # left {float: left; width: 200px Height: 300px; background-color: pink; margin-left:-100%; position: relative; left:-220px;} # center {float: left Width: 100%; height: 300px; background-color: red;} # right {float: left; width: 200px; height: 300px Background-color: yellow; margin-left:-200px; position: relative; right:-220px } these are all the contents of the article "how to achieve the three-column layout of CSS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Layout content article study help one line three code elements principles attributes easy to understand more organization knowledge space ribbon freeing industry negative value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn macOS OPPO Reno MariaDB Shulou Information