css - 嵌套 CSS 问题

标签 css

我创建了 fiddle 来展示示例:我想我正在设置父级 CSS,然后应用子级的 CSS。但它似乎被忽略了。

http://jsfiddle.net/8PWNw/2/

<div id="displaybox" class ="displaybox" style="display: none;">
    <div class = "parent" >
        <a href="reply.php?id=1">Parent 1</a>
    </div>
    <span  class ="child"  style="padding: 0 10 "><a href="reply.php?id=3">Child 1</a></span>
    <div class = "parent" >
        <a href="reply.php?id=2">Parent 2</a>
    </div>
    <span  class ="child"  style="padding: 0 10 "><a href="reply.php?id=4">Child 1</a></span>
</div>

请指教。我是 CSS 新手,所以我需要学习很多东西。

最佳答案

CSS 中的第 23 行:

/* this is actually saying element with both 'parent' and 'a' class */

    .displaybox .parent.a {
        color: black; 
    }

你的意思可能是:

/* this is actually saying all 'A' elements within element with 'parent' class */

    .displaybox .parent a {
        color: black; 
    }

这就是为什么您的“A”元素样式被忽略的原因。

关于css - 嵌套 CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16274164/

相关文章:

HTML 电子邮件 : How to make image overlapping border?

html - 移动端模态消失

html - 如何用一个元素创建 3D 透视图像?

javascript - 在 Chrome 移动浏览器中禁用图像压缩

html - 在 div 上使用固定位置时出现意外行为

css - 居中第一个标题,使第二个标题从第一个标题开始的地方开始

html - 重新定义选择器以用于其余代码的不同方式

html - CSS Flex - Space Between 但左对齐元素?

css - 我无法修复正文和页脚之间的差距

html - 无法完全收缩包裹并居中元素