CSS:<\/p>\n
form div {font-size: 12px; font-weight: bold;}\ndiv.content\n{\n \/* Can anything go here? *\/\n}<\/pre>\n正常情況下,文字會屏蔽「Content of the paragraph」和「Content of the span」將從父親「form div」元素繼承字體大小和粗細,導(dǎo)致兩個文字都是粗體和 12px。 <\/p>\n
要防止這種繼承並將樣式限制為僅“段落內(nèi)容”,可以手動恢復(fù)樣式更改:<\/p>\n
div { color: green; }\n\nform div { color: red; }\n\nform div div.content { color: green; }<\/pre>\n或者,如果可能的話,向標(biāo)記添加其他類可以提供更精確的樣式:<\/p>\n