* Improve usage share * Remove 'No caveats' note from all snippets * Fix transform-centering usage: #search -> #feat * transform -> transforms2d * Add missing link for multiline truncate
832 B
832 B
Sibling fade
Fades out the siblings of a hovered item.
HTML
<div class="sibling-fade">
<span>Item 1</span> <span>Item 2</span> <span>Item 3</span> <span>Item 4</span>
<span>Item 5</span> <span>Item 6</span>
</div>
CSS
span {
padding: 0 1rem;
transition: opacity 0.2s;
}
.sibling-fade:hover span:not(:hover) {
opacity: 0.5;
}
Demo
Explanation
transition: opacity 0.2sspecifies that changes to opacity will be transitioned over 0.2 seconds..sibling-fade:hover span:not(:hover)specifies that when the parent is hovered, select anyspanchildren that are not currently being hovered and change their opacity to0.5.