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
netem and tc: netem is a network simulation modul...
Table of contents Preface: Encryption algorithm: ...
Problem to be solved Mainly for cross-level commu...
introduction: Nowadays, many dynamic verification...
Table of contents Arithmetic operators Abnormal s...
1. Block-level element: refers to the ability to e...
Summarize This article ends here. I hope it can b...
Download MySQL for Mac: https://downloads.mysql.c...
RGB color table color English name RGB 16 colors ...
A long time ago, I summarized a blog post titled ...
Preface Today, I was reviewing the creational pat...
As you build and scale your Django applications, ...
Table of contents Preface Creating Components Sum...
Preface In project development, there are many wa...
Personally, I think the decompressed version is e...