-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathcss-has.html
199 lines (164 loc) · 3.64 KB
/
css-has.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<div class="post">
<h2>Post</h2>
<a href="#">I'm a link</a>
</div>
<div class="post">
<h2>Post</h2>
</div>
<style>
.post:has(h2):has(a) {
background: var(--white);
}
.post {
padding: 5px;
margin: 5px;
}
</style>
<body>
<nav>
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/work">Work</a>
<ul>
<li><a href="/podcast">Podcast</a></li>
<li><a href="/courses">Courses</a></li>
</ul>
</li>
<li><a href="/contact">Contact</a>
<ul>
<li><a href="/podcast">Podcast</a></li>
<li><a href="/courses">Courses</a></li>
</ul>
</li>
</ul>
</nav>
<style>
:root {
--white: rgba(255, 255, 255, 0.2);
--black: rgba(0, 0, 0, 0.6);
--padding: 20px;
}
li:has(ul)>a:after {
content: '↓';
}
body {
/* display: grid;
justify-content: center;
align-items: center; */
}
nav {
border: 1px solid var(--black);
background: var(--white);
border-radius: 15px;
}
nav a {
padding: var(--padding);
display: block;
text-decoration: none;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
display: inline-block;
position: relative;
}
ul a {
position: relative;
}
ul li ul {
position: absolute;
left: var(--padding);
transform: translateY(0);
border: 1px solid var(--black);
background: var(--white);
opacity: 0;
transition: opacity 0.1s;
}
ul li:hover ul {
opacity: 1;
}
ul li ul li {
list-style: circle;
}
ul li ul a {
padding: 10px;
}
/*
Oh Hello!
These are some base styles so that our tutorial looks good.
Let's go through the important bits real quick
*/
:root {
--yellow: #ffc600;
--black: #272727;
}
a {
color: white;
}
html {
/* border-box box model allows us to add padding and border to our elements without increasing their size */
box-sizing: border-box;
/* A system font stack so things load nice and quick! */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-weight: 600;
color: var(--black);
}
/*
WAT IS THIS?!
We inherit box-sizing: border-box; from our <html> selector
Apparently this is a bit better than applying box-sizing: border-box; directly to the * selector
*/
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
background-image: url("./images/topography.svg"),
linear-gradient(110deg, #f93d66, #6d47d9);
background-size: 340px, auto;
min-height: calc(100vh - 100px);
margin: 50px;
/* background: white; */
background-attachment: fixed;
letter-spacing: -1px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0 0 5px 0;
}
/* Each item in our grid will contain numbers */
.item {
/* We center the contents of these items. You can also do this with flexbox too! */
display: grid;
justify-content: center;
align-items: center;
border: 5px solid rgba(0, 0, 0, 0.03);
border-radius: 3px;
font-size: 35px;
background-color: var(--yellow);
}
.item p {
margin: 0 0 5px 0;
}
</style>
</body>
</html>