-
Notifications
You must be signed in to change notification settings - Fork 1
/
quantity-queries.astro
58 lines (56 loc) · 1.27 KB
/
quantity-queries.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
55
56
57
58
---
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;
border: var(--border);
}
.card:has(> *:nth-child(4n)) {
background: #FF474E;
}
</style>
<BaseLayout title="Quantity Queries">
<div class="description">
<p>Select an element based on the number of children it has.</p>
<p>In this example we change the style of any card with 4 or more elements.</p>
</div>
<ThemedCode lang="css" code=`.card:has(> *:nth-child(4n)) {
background: #FF474E;
}` />
<div class="cards">
<article class="card">
<div>one</div>
</article>
<article class="card">
<div>one</div>
<div>two</div>
</article>
<article class="card">
<div>one</div>
<div>two</div>
<div>three</div>
</article>
<article class="card">
<div>one</div>
<div>two</div>
<div>three</div>
<div>four</div>
</article>
<article class="card">
<div>one</div>
<div>two</div>
<div>three</div>
<div>four</div>
<div>five</div>
</article>
</div>
</BaseLayout>