Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
すべてのdivにcssオプションがあります
div { background: blue; }
myDiv以外のcssオプションを継承しないidでdivを作成するにはどうすればよいですか#myDiv。
myDiv
#myDiv
それができないので、カスケードスタイルシートと呼ばれています。
このような場合の最も一般的な解決策は、background属性#myDivを別のルールでオーバーライドすることです。
background
この特定のケースでは、のようにCSS3:not疑似クラスを使用するオプションがありますが、ブラウザーの互換性div:not(#myDiv) { background: blue }を考慮する必要があります(要約:IE <9を除くすべてで機能します)ので、これは実用的ではないと思いますまだオプション。
:not
div:not(#myDiv) { background: blue }