Disinherit(重置)特定元素的CSS样式? [英] Disinherit (reset) the CSS style of a specific element?

查看:111
本文介绍了Disinherit(重置)特定元素的CSS样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个漂亮的网络,它的样式在一个CSS和一切

Ok, I have a beautiful web, with its styles within a CSS and everything

但现在我发现一个问题,我想要一个列表是处女,没有任何风格继承。

But now I've found a problem, I want ONE list to be virgin, without any style inherited.

我知道我可以做它只是给它一个 style =(...)所以它覆盖了继承的风格,但是,有没有任何指令/技巧/东西做,而不这样做?

I know I can do it just giving it a style="(...)" so it overwrites the inherited style, but, is there any instruction / trick / something to do it without doing this?

推荐答案

p> CSS级联和继承第3级规范介绍了同时重置所有属性的功能。这是通过使用简写属性 all 与值 初始 unset ,具体取决于您是否需要重置继承的属性。

CSS Cascading and Inheritance Level 3 specification introduces ability to reset all properties at once. This is achieved by using the shorthand property all with value initial or unset depending on whether you need to reset inherited properties.

请注意,这些与浏览器 -

Note that these have nothing to do with browser-default values.

此功能适用于Firefox 27+,Chrome 37+和Opera 24 +。

The feature is available in Firefox 27+, Chrome 37+, and Opera 24+.

直到功能被广泛实现,你可以使用命名空间类。例如,为了将布局样式与内容样式分开,我通常使用 content 类作为所有内容样式的命名空间。

Until the feature is widely implemented, you can use "namespace" classes. For example, to separate layout styles from content styles, I usually use content class as a namespace for all content styles.

简化示例:

/* Global styles for UL lists. */
UL {list-style: none; margin: 0; padding: 0; }

/* Styles for UL lists inside content block. */
.content UL {list-style: disc; margin: 1em 0 1em 35px; }

这篇关于Disinherit(重置)特定元素的CSS样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆