Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).

Draft
This page is not complete.

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The ::part CSS pseudo-element represents any element within a shadow tree that has a matching part attribute.

custom-element::part(foo) {
  /* Styles to apply to the `foo` part */
}

Syntax

::part( <ident>+ )

Examples

<tabbed-custom-element>

<tabbed-custom-element> shadow tree

<style type="text/css">
  *, ::before, ::after {
    box-sizing: border-box;
  }

  :host {
    display: flex;
  }
</style>
<div part="tab active">
  Tab 1
</div>
<div part="tab">
  Tab 2
</div>
<div part="tab">
  Tab 3
</div>

Stylesheet loaded in light tree

 
tabbed-custom-element::part(tab) {
  color: #0c0c0dcc;
  border-bottom: transparent solid 2px;
}

tabbed-custom-element::part(tab):hover {
  background-color: #0c0c0d19;
  border-color: #0c0c0d33;
}

tabbed-custom-element::part(tab):hover:active {
  background-color: #0c0c0d33;
}

tabbed-custom-element::part(tab):focus {
  box-shadow:
    0 0 0 1px #0a84ff inset,
    0 0 0 1px #0a84ff,
    0 0 0 4px rgba(10, 132, 255, 0.3);
}

tabbed-custom-element::part(active tab) {
  color: #0060df;
  border-color: #0a84ff !important;
}

Specifications

Specification Status Comment
Unknown
The definition of '::part' in that specification.
Unknown Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
::part
Experimental
Chrome Full support 73Edge No support NoFirefox Full support 69
Disabled
Full support 69
Disabled
Disabled From version 69: this feature is behind the layout.css.shadow-parts.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 60Safari No support NoWebView Android Full support 73Chrome Android Full support 73Firefox Android No support NoOpera Android ? Safari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Метки документа и участники

Внесли вклад в эту страницу: rachelandrew, ExE-Boss, mfuji09
Обновлялась последний раз: rachelandrew,