CSS元素恢复为默认样式 [英] CSS element back to default style

查看:511
本文介绍了CSS元素恢复为默认样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CSS中是否有一种快速的方法来删除应用于元素的所有样式?例如,说出某种标签菜单:

Is there a fast way in CSS to remove all of the styles applied to an element? For example, say a tab menu of some sort:

<div class='outer'>
  <div id='d1'></div>
  <div id='d2'></div>
  <div id='d3'></div>
  <div id='d4'></div>
</div>

已应用CSS ...

The CSS is applied...

.outer {foo:blee; bar:blah; bas-bloo:浮潜; / * ...很长的清单... * /}

现在,我要#d3 (例如)返回默认样式,但我不想显式取消设置所有父样式:

Now, I want #d3 (for example) to return to default styling, but I don't want to explicitly unset all of the parent styles:

#d3 {remove-styles:all} / *<-[[我显然是这么做的] * /

管道梦或

推荐答案

在CSS3中,是的。您可以使用否定伪类

In CSS3, yes. You could use the negation pseudo-class:

.outer:not(#d3) { foo:blee; etc etc }

目前大多数浏览器都缺少对CSS3的糟糕支持...

Too bad CSS3 support is a little lacking at the moment with most browsers...

CSS级别小于3时,您就被搞砸了。抱歉。

With CSS level less than 3, you're screwed. Sorry.

这篇关于CSS元素恢复为默认样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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