Introduction of horizontal Centering method using Fit-content in CSS3

Source: Internet
Author: User
Today through this article to introduce a Fit-content property of the relevant knowledge, CSS properties are used to center horizontally, Fit-content is CSS3 to the width property of a new attribute value, which with margin can let us easily achieve horizontal center effect; Let's see the code together.

When we let a module horizontal center The first thought is certainly margin:0 auto; So today to introduce a fit-content attribute, do not know if there are students have used, if used so you can skip this article, the students have no use to continue, I also see this property for the first time, I do not know this attribute, let alone use, originally this CSS property is used for the horizontal center , Fit-content is a new attribute value for the Width property in CSS3, which can be used to make it easy to achieve horizontal centering effect; Let's take a look at the code.

If the width is not set and the element is centered with Float:left, look at a piece of code first:

So this navigation is not centered, when we set the Fit-content plus margin to do the centering.

Currently this property only supports Chrome and Firefox browser, the following is the center of the Code:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.