我在上發現了這個問題,我想知道它解決了哪些問題,而這些問題無法用CSS中的當前操作完成。例如,新的「scoped CSS」有什麼用?
<div>
<style scoped>
h1 { color: FireBrick; }
p { color: SaddleBrown; }
</style>
<h1>This is an H1 in a scoped div.
Regardless of global styles the text should be "FireBrick".
</h1>
<p>This is a paragraph in a scoped div. The text should be "SaddleBrown".</p>
</div>
<p>This is another paragraph,
that will unaffected by the scoped style and remain black.</p>
很容易做到的
<style>
div.scoped h1 { color: FireBrick; }
div.scoped p { color: SaddleBrown; }
</style>
<div class="scoped">
<h1>This is an H1 without scoped div.
Regardless of global styles the text should be "FireBrick".
</h1>
<p>This is a paragraph without scoped div.
The text should be "SaddleBrown".</p>
</div>
<p>This is another paragraph,
that will unaffected by the scoped style and remain black.</p>
還是我缺少什麼?
編輯
是不是該重新引入內嵌樣式,最不利的造型的三種方式?
SO用於解決問題。這個問題似乎更多的是「這個解決方案是否存在問題?」,因此是廣泛的,理論性的,部分是推測性的。 –
@Jukka - 嗯,我的問題描述了我的問題,這是我不知道它的好處。** SO是爲了獲得問題的答案,對嗎?** :-) – stevenvh