-
Notifications
You must be signed in to change notification settings - Fork 1
/
all-siblings.astro
54 lines (51 loc) · 1.14 KB
/
all-siblings.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
import ThemedCode from '../components/ThemedCode.astro';
import BaseLayout from '../layouts/BaseLayout.astro';
---
<style is:global>
.cards {
display: flex;
justify-content: center;
}
.card {
background: #000;
margin: 0.25rem;
padding: 1rem;
display: inline-block;
cursor: pointer;
border: var(--border);
}
.card:hover {
transform: scale(1.2);
background: #FF474Eee;
}
.cards:has(.card:hover) .card:not(:hover) {
opacity: 0.2;
}
</style>
<BaseLayout title="All Siblings">
<div class="description">
<p>Select all siblings of a given element.</p>
<p>In this example, if a card is being hovered, we change the style of all card elements that are not being hovered.</p>
</div>
<ThemedCode lang="css" code=`.cards:has(.card:hover) .card:not(:hover) {
opacity: 0.2;
}`; />
<section class="cards">
<article class="card">
One
</article>
<article class="card">
Two
</article>
<article class="card">
Three
</article>
<article class="card">
Four
</article>
<article class="card">
Five
</article>
</section>
</BaseLayout>