Some situations caused by priority problems in CSS

Source: Internet
Author: User
Tags comments
When developing front-end web pages on a website, you may encounter some strange problems from time to time. Sometimes, it is still difficult to understand. This is not the case. I encountered a problem that surprised me a few days ago: I did not display the wordpress comments when I replied, but the comments could be normally displayed. Initially thought it was a code problem and the result was not. Because the comments in the article are normally displayed, and the comments in the Atlas slides cannot be displayed. What's going on?

After multiple searches, I finally found the problem, as shown in the figure below:

Wordpress automatically adds the style property to the children label, so that the style I defined in the theme style.css does not work. Dizzy. What should we do? I want to solve the problem only when the style in my style.css takes precedence over the style automatically added by wordpress. In CSS, how does one take precedence over style? Only pass! Important;, because this level is the highest and the highest priority. Fortunately, this attribute is not automatically added to wordpress. So I added the related tags! Important; solve the problem.
The code is as follows: Copy code
Ul. children {width: 610px! Important; left: 50px! Important; position: relative; overflow: hidden; padding: 0px; margin: 30px ;}
Ul. children li. comment {width: 100%! Important ;}

The following describes the CSS priority:

[1 important flag]> [4 special symbols]> declaration order

! Important> style> [id> class> tag]

Use! Important can change the priority level to the highest level, followed by the style object, followed by id> class> tag. In addition, the style displayed after the same level style follows the declarative order has a high priority.

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.