--- title: '::part()' slug: 'Web/CSS/::part' tags: - '::part' - CSS - Draft - Exp - NeedsBrowserCompatibility - NeedsExample - Pseudo-element - Reference translation_of: 'Web/CSS/::part' ---
Le pseudo-élément CSS ::part représente n’importe quel élément dans un arbre fantôme qui a un attribut {{HTMLAttrxRef("part")}} correspondant.
custom-element::part(foo) {
/* Styles à appliquer à la partie `foo` */
}
<tabbed-custom-element><tabbed-custom-element><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>
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;
}
| Spécification | État | Commentaires |
|---|---|---|
| {{SpecName("CSS Shadow Parts", "#part", "::part")}} | {{Spec2("CSS Shadow Parts")}} | Définition initiale. |
{{Compat("css.selectors.part")}}
::part()::part et ::theme