CSS3 tip: fit-content horizontal center, css3fit-content
When we center a module horizontally, the first thing we think of is margin: 0 auto; is there wood? So today, I will introduce you to the fit-content attribute. I don't know if anyone has used it. If you have used it, you can skip this article. If you have never used it, you will continue, I also saw this attribute for the first time. I didn't know it before, let alone use it. Originally, this CSS attribute was used for horizontal center, fit-content is a new property value added to the width attribute in CSS3. It works with margin to make it easy to implement the horizontally centered effect. Let's take a look at the code.
If the width is not set and the element contains float: left, the center is centered. first look at the Code:
In this case, the navigation will not be centered. When we set fit-content and margin, we will center the navigation.
Currently, this attribute only supports Chrome and Firefox browsers. The following code is centered:
Can you try it in the editor? Hope it will be useful to everyone ......
I would like to likes some of the great gods who provide solutions ......