知りたいこと
Custom Element をいじっていたところ妙な挙動に気付きましたので理由を知りたいです。
下記➂にございますように、なぜか background
の反映のためには、display
指定 および ラップ要素が必要になるのです。
要素名 | display 指定 | ラップ要素 | background の反映 | |
---|---|---|---|---|
➀ | <custom-area1> | ❌なし | ❌なし | 👎効かない |
➁ | <custom-area2> | ✅あり | ❌なし | 👎効かない |
➂ | <custom-area3> | ✅あり | ✅あり | 🎉効く |
該当のソースコード
https://jsfiddle.net/0fjzhb59/
html
1<custom-area1> 2 <p>custom-area1</p> 3 <style> 4 wrapper-area { 5 background: aquamarine; 6 } 7 </style> 8</custom-area1> 9 10<custom-area2> 11 <p>custom-area2</p> 12 <style> 13 wrapper-area { 14 background: aquamarine; 15 display: block; 16 } 17 </style> 18</custom-area2> 19 20<div> 21 <custom-area3> 22 <p>custom-area3</p> 23 <style> 24 custom-area3 { 25 background: aquamarine; 26 display: block; 27 } 28 </style> 29 </custom-area3> 30</div>
一体どういう経緯や理由によって、➀➁は効かず、➂でのみ効くのでしょうか?
回答2件
あなたの回答
tips
プレビュー