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
In my last post I talked about how to make a web p...
Preface Believe me, as long as you remember the 7...
I. Introduction First, let me explain the version...
System environment: Windows 7 1. Install Docker D...
Table of contents Preface text 1. Panel 2. Huaron...
Table of contents 1 What is SSH 2 Configure SSH p...
Two ways to navigate the page Declarative navigat...
Table of contents Preface: What is waterfall layo...
MySQL consistency log What happens to uncommitted...
[LeetCode] 185. Department Top Three Salaries The...
Table of contents 1. Lock and Latch 2. Repeatable...
First, we need to use the transform-origin attrib...
This article uses examples to illustrate the prin...
If we want to perform batch operations on a type ...
Setting the font for the entire site has always b...