Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use CSS to realize three-column layout

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report