css3 - css怎么取消元素属性
PHP中文网
PHP中文网 2017-04-17 11:04:23
0
3
510

目前遇到一个问题,请大神指点:dasdig.css中有个

.text_color{color: #f0ad4e;}

dasdig2.css中也有个

.text_color{color: ;},

现在有个dasdig.html,里面先加载的dasdig.css,然后再加载dasdig2.css,如下:

<link href="__STATIC__/dasdig.css" rel="stylesheet">
<link href="__STATIC__/dasdig2.css" rel="stylesheet">

我在dasdig2中怎么设置.text_color的颜色属性,能实现将颜色属性消失,即不再出现任何颜色属性?

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
黄舟

1. The name of CSS is Cascading Style Sheet, which has the characteristic that properties defined later overwrite previously defined properties.
2.

The color attribute disappears, that is, no color attribute appears anymore?

颜色属性消失是什么意思, are you trying to make color invisible?
Or do you want .text_color的颜色 to inherit the color attributes of its parent?
Or make its color transparent (the element will not be visible)?

The former can only be achieved through javascript code, such as http://www.w3school.com.cn/jquery/jquery_ref_attributes.asp or http://www.w3school.com.cn/jsref/dom_obj_attributes.asp;
The latter can be inherited from the parent by setting color:inherit Properties,
To achieve the transparency effect, you can use the color:transparent attribute

巴扎黑

If you no longer need to display the text in the element, you can hide it or use negative indentation; and in the later introduction, set the text color to a transparent color color: transparent;, as in the following example:

http://jsfiddle.net/65PLY/1/

Ty80

Inherit

css.text_color{
    color:inherit;
}

Transparent

css.text_color{
    color:transparent;
}

Flush out (#box has a p id of text_color, it can be flushed out no matter where it is)

css#box p.text_color{
    color:red;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template