As the title says: The height is known, the width of the left and right columns is 300px, and the middle is adaptive: The elastic box itself is side by side, we just need to set the width. Use a container to wrap the three columns, set the display property of the container to flex, set the width of the left and right columns to 300px, and set flex:1 for the middle column. Here 1 represents the width ratio. The specific value depends on the flex value of other boxes. Since the width of other boxes is fixed here, the middle column will be automatically filled: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Three-column layout</title> </head> <style type="text/css"> html*{ margin: 0; padding: 0; } .container{ display: flex; } .left{ background-color: aqua; width: 300px; height: 100px; } .center{ height: 100px; flex: 1; background: #f296ff; } .right{ height: 100px; background-color: #6ee28d; width: 300px; } </style> <body> <!-- Given the height, write a three-column layout with 300px width on the left and right and adaptive width in the middle --> <div class="container"> <div class="left"></div> <div class="center"></div> <div class="right"></div> </div> </body> </html> The effect is as shown below: This concludes this article about how to use CSS3 flexible box flex to implement a three-column layout. For more information about CSS3 flex three-column layout, please search 123WORDPRESS.COM’s previous articles or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: How to use html css to control div or table to be fixed in a specified position
>>: Install JDK1.8 in Linux environment
Preface Named slots are bound to elements using t...
This article example shares the specific code of ...
You need to add "gt_" in front of the f...
This article describes the Linux file management ...
As a lightweight open source database, MySQL is w...
Yum (full name Yellow dog Updater, Modified) is a...
1. What affects database query speed? 1.1 Four fa...
Overview Prometheus is an open source service mon...
A few days ago, I found that the official version...
After installing VMware and creating a new virtua...
Which parameter does the rpm command use to insta...
This article example shares the specific code of ...
Mainly use the preserve-3d and perspective proper...
Table of contents 1. Count data is lost Solution ...
DOCTYPE DECLARATION At the top of every page you w...