Home>Article>Web Front-end> How to remove attributes in css

How to remove attributes in css

藏色散人
藏色散人 Original
2021-04-08 10:22:17 4749browse

How to remove attributes in css: first open the corresponding front-end code file; then find the attribute value that needs to be removed; finally, by setting the unset attribute for a certain keyword, the effect of removing the specified attribute can be achieved.

How to remove attributes in css

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

Reset or remove a certain css attribute value

There are the following scenarios:

You use someone else’s UI framework, and then you find that you The value dynamically assigned to the css is overwritten by the higher priority css of the UI framework. You can write js to change it, but if there are many layers of loop operations, you need to write a large section of js. At this time, js is not the best choice. What you really need is the 'unset' attribute

Unset priority

If unset is set for a certain keyword, such as color: unset; it will first choose to inherit the parent's attributes, and then choose to inherit its own attribute value, that is: inherit > initial

For example:

The attribute values p and span set the color value. If unset is set, the color value of h_bg will be selected to inherit.

HTML:

title title title

text text text

CSS:

p{ color:red; } span{ color:blue; } .h_bg{ color:#FFF; background:#DEDEDE; padding:20px; text-align:center; width:200px; height:200px; } .reset{ color:unset; //去掉这个属性,文字会优先使用span和P的color值 }

[Recommended learning:css video tutorial]

The above is the detailed content of How to remove attributes in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn