A CSS layout and style question: how to balance horizontal centering and limiting maximum width In recent work, I encountered a problem like this: 1. Background
2. Implementation ideas The overall container needs to add properties: .container { display: flex; justify-content: center; } 2.1 Use flex:1 to achieve In the previous code, the column that changes is set to flex: 1 or flex: auto, but the problem is that this will take up all the remaining space in the container and will not automatically adjust according to the content; 2.2 Set flex: none to achieve The problem with this is that when there is too much content, it will not cover the excessive content. 2.3 Not setting properties If the content in the middle is not fixed, do not set any flex attributes. If it is not enough, remember to overwrite it: .clamp { flex: initial; } Note that initial is used here instead of none. Also be careful not to squeeze the width of other columns. There was originally a picture in the left column, and the width was set, but because there was too much content in the middle column, the picture was compressed and deformed. Therefore, a min-width attribute is added to the image. This is the end of this article about how to horizontally center with CSS and limit the maximum width. For more information about how to horizontally center with CSS and limit the maximum width, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: JavaScript implements bidirectional linked list process analysis
>>: A Brief Analysis of MySQL Connections and Collections
First of all, let me talk to you about my daily l...
In our daily development work, text overflow, tru...
Table of contents background 1. The query conditi...
Table of contents 1. Overview 1. Explain statemen...
Preface I once encountered a difficult problem. I...
1. Changes in MySQL's default storage engine ...
How to install Linux CentOS 7.7 system in Vmware,...
By default, Docker runs over a non-networked UNIX...
1. The role of index Generally speaking, an index...
Good HTML code is the foundation of a beautiful w...
The configuration method of MySQL 5.5.56 free ins...
Uninstall tomcat9 1. Since the installation of To...
Preface I encountered a Mysql deadlock problem so...
Preface Today I encountered a very strange proble...
The fastest way to experience the latest version ...