【问题标题】:What is the difference between these two CSS expressions? [duplicate]这两个 CSS 表达式有什么区别? [复制]
【发布时间】:2014-05-14 18:45:45
【问题描述】:

我有两个 css 表达式:

.firstexpression.secondexpression (without space)

.firstexpression .secondexpression (with space)

有什么区别?

【问题讨论】:

标签: css


【解决方案1】:

第一个适用于应用了 BOTH 类的元素,第二个适用于带有 .secondexpression 的子元素,其父元素带有 .firstexpression

.firstexpression.secondexpression{
   /* styles */
}

适用于:

<div class='firstexpression secondexpression'>Applies to this element</div>

对比..

.firstexpression .secondexpression{
   /* styles */
}

适用于:

<div class='firstexpression'>
   <div class='secondexpression'>Applies to this element only</div>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多