css - 不工作的 CSS 选择器

标签 css list selector children

我的脑袋快要爆炸了。请检查这个 fiddle :

http://jsfiddle.net/337C7/1/

section ul li {
    text-decoration: underline;
}

section ul li ul li {
    text-decoration: none !important;
}

基本上我有一个无序列表,里面还有另一个。我只是想删除 child ul 上的文字装饰。无论出于何种原因,它都不想工作。我是不是很傻?

最佳答案

根据 MDN :

Text decorations draw across descendant elements. This means that it is not possible to disable on a descendant a text decoration that is specified on one of its ancestors.

For example, in the markup: <p>This text has <em>some emphasized words</em> in it.</p> the style rule:p { text-decoration: underline } would cause the entire paragraph to be underlined. However, the style rule: em { text-decoration: none } would not cause any change; the entire paragraph would still be underlined. (However, the rule em { text-decoration: overline } would cause a second decoration to appear on "some emphasized words".)

关于css - 不工作的 CSS 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20228940/

相关文章:

html - CSS - 选择下一个元素

java - 使用通配符将项目添加到列表时出错

python - 如何检查列表中的所有元素是否相同?

html - 为什么在 HTML 元素上使用类或 ID?

ios - 在 swift 3 中,按钮单击应用程序崩溃,与 Storyboard绑定(bind)

python - '类型错误: 'NoneType' object is not subscriptable' about lists

css - 为什么 css hover 只影响书签?

html - h1 标签的高度有问题,似乎是从另一个对象继承的

html - 删除 outlook 中 html 电子邮件周围的空间

html - 如何使此文本与我的图像一致?布局问题