Fit-content implementing Element Horizontal centering

Source: Internet
Author: User
This time to bring you fit-content to achieve the element level center, fit-content to achieve the elements of the level of attention to the center of the matter, the following is the actual case, together to see.

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:

Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!

Recommended reading:

CSS3 pointer-events use of the detailed

Using CSS to implement element centering

How Font-size-adjust properties Optimize page layout

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.