id
このようにCSSを「ネスト」するつもりでした
#content #caption { color: teal }
...
#footer #caption { margin: 2em 1em }
それがSASS(CSSジェネレーター)がネストを行う方法だからです...しかし、1つのHTMLドキュメントではid
、同じ名前の2つのを持つことはできません。そうではないので、上記のネストは機能しないか、勝ちます。うまくいきません。(特に、要素を選択するためにdocument.getElementById()または$('#caption')または$('caption')が必要な場合)。
使用できます
#content #content_caption { color: teal }
...
#footer #footer_caption { margin: 2em 1em }
しかし、なぜもう1レベルのネストがあるのでしょうか。なぜだけではないのですか
#content_caption { color: teal }
...
#footer_caption { margin: 2em 1em }
?