directly?)
一般来说,当我们有一些应该一起设置样式的子元素时,我们应该将该样式放到父级并让继承工作,还是给孩子们自己? 例如,如果我们有如下结构:
<div class="foo">
<p>should be 2em</p>
<ul>
<li>should be 2em</li>
<li>should be 2em</li>
</ul>
</div>
然后我应该这样做:
.foo {font-size: 2em}
或类似的东西?:
.foo p, .foo li {font-size: 2em}
我认为这个问题非常基本,但很抱歉我找不到任何好的谷歌搜索结果。
Generally speaking, when we have some child elements that should be styled together, should we put that style to the parent and let the inheritance work, or to the children themselves? For example, if we have a structure as below:
<div class="foo">
<p>should be 2em</p>
<ul>
<li>should be 2em</li>
<li>should be 2em</li>
</ul>
</div>
then should I make it as this:
.foo {font-size: 2em}
or something like this?:
.foo p, .foo li {font-size: 2em}
I think this question is very basic, but sorry I couldn't find any good google result.