How to use CSS to realize three-column layout
This article is about how to use CSS to implement a three-column layout. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
CSS implements three-column layout (fixed 200px left and right, adaptive in the middle)
Double wing layout: both float to the left, the tundish has a box, and the padding separates the width on both sides. There are margin-left on both the left and right sides.
Body {min-width: 550px;} .col {float: left;} # main {width: 100%; height: 400px; background-color: # ccc;} # main-wrap {margin: 0 200px 0200px;} # left {width: 200px; height: 400px; margin-left:-100% Background-color: red;} # right {width: 200px; height: 400px; margin-left:-200px; background-color: # ff0000;}
Holy Grail layout: there is no box in the middle, but there is still a padding.
# container {padding: 0 190px 0 190px;} .col {position: relative; float: left;} # main {width: 100%; height: 400px; background-color: # ddd;} # left {width: 190px; height: 400px; background-color:red; / * distance from the left margin itself * / margin-left:-100% / * then move its own width to the left * / left:-190px;} # right {width: 190px; height: 400px; background-color: yellow; margin-left:-190px; right:-190px;}
Expand the left and right layout
Html,body {height: 100%;} .left {width: 256px; height: 100%; background-color: # ddd; float: left;} .right {width: 100%; height: 100%; margin-left: 256px; background-color: rgb (230,48,48);} Thank you for reading! This is the end of the article on "how to use CSS to achieve three-column layout". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!