我可以帮您翻译成中文,“我想为所有标题应用格式。”“因此,我添加了以下内容”的意思。
.myformat h1, h2, h3, h4, h5, h6 { margin-bottom : 1em; ... }
这样写的话,它并不考虑第一个hx
。规则不适用于h1。
当我像这样写:
.myformat h1, h2, h3, h4, h5, h6, h1 { margin-bottom : 1em; ... }
一切都好。规则适用于h1、h2、...和h6。
这很可疑...我猜我在别的地方有问题,但我看不到它。
将规则应用于多个选择器的方法是否正确?
我在window上的IE9和Chrome20上以及Fedora15上的Firefox12中复制了这个行为。
编辑
我想能够做类似这样的事情
<h1 class="myformat">This text will be red and
or all hx where I apply "myformat"
</h1>
<p class="myformat">This text will be yellow only
when myformat is applied on a paragraph
</p>
我创建了.myformat h1, h2, h3, h4, h5, h6 { margin-bottom : 1em; ... }
,认为这个"myformat"只会应用于标题。
我本来要创建.myformat p { margin-bottom : 3em; ... }
但我卡在了<h1 class="myformat">text</h1>
h1
。不确定你发现了什么可疑的地方。选择器.myformat h1
只选择.myformat
的子元素中的h1
... 这对你有所帮助吗?你期望.myformat
做什么,为什么要使用它? - Wesley Murch.myformat h1
而不是只用h1
? - Wesley Murch