The value problem of the same attribute in CSS class overlay

Source: Internet
Author: User

For an element that uses more than one class, where one property value has different values in multiple classes, the final element of the attribute takes that value.

High priority overrides are of course low priority.

Consider a CSS link file box for an HTML file.

In CSS:

. form-control{width:100%;..}. width-control{width:60%;}


In HTML:

1. <div class= "Form-control Width-control" >...</div>2. <div class= "Width-control Form-control" >...</div>


above in HTML Change the writing order of the class and find that the valid values are width:60% , stating that the HTML in a class in the sequence of books written in parallel does not affect the order of coverage .


Change the order defined in the CSS, as follows:

. width-control{width:60%;}. form-control{width:100%, ...}

the valid values at this time are width:100%, This indicates that the class Precedence is determined by the class in the CSS the order defined in the file determines : The more you define the higher the priority level!




The value problem of the same attribute in CSS class overlay

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.