shadow DOM styles
Web Components โฉ Shadow DOM โฉ
MDN โฉ
CSS โฉ
Google โฉ
Web Component โฉ Component-defined styles
:host, :host(), :host-context(), ::slotted()
:host, :host(), :host-context() only works in the context of a shadow root, you can't use it outside of shadow DOM.
โญ๏ธ ๆณจๆ๏ผ
ๅฆๆๅๆๅจ shadow DOM ่ light DOM ไธญๅๅฅ็จ
:host
่ custom-element selector ๅฐ<custom-element>
ๅ CSS ๆ ผๅผ่จญๅฎ๏ผๅๅค้จ็ๆ ผๅผๅ ทๆๅชๅ ๆฌใๆๅๅฏไปฅๅฉ็จ้็จฎ็นๆง๏ผไฝฟ็จ :host ๅฐ <custom-element> ่จญๅฎ้ ่จญๆ ผๅผ๏ผ็ถๅพๅจๅค้จ็ CSS ไธญๅไฝฟ็จ custom-element ่จญๅฎ่ช่จๆ ผๅผใ
Topics
Examples
:host - <custom-dialog>, <user-card>, <element-details>
:host() - <custom-dialog>, <element-details>
::slotted() - <user-card>, <element-details> ๐ slotted content
Last updated