-
-
Notifications
You must be signed in to change notification settings - Fork 258
/
Copy pathstyles.css
183 lines (181 loc) · 3.97 KB
/
styles.css
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
/* Here's our design
It's fonts, colours, and spacing.
Every design is made of these basic building blocks.
Change the values in Devtools */
:root {
/* fonts */
--copy: monospace;
/* colours */
--paper: hsla(260, 35%, 90%, 0.95);
--ink: hsla(270, 8%, 20%, 0.98);
--brand: hsla(0, 100%, 67%, 0.98);
--shade: hsla(270, 8%, 20%, 0.1);
/* spacing */
--space: 2rem;
--box: 18rem;
--container: clamp(var(--box), calc(100vw - calc(var(--space) * 2)), 74rem);
--finger: 48px;
--line-length: 60ch;
}
/* What does this rule do? Try removing it. */
* {
box-sizing: border-box;
}
/* What about this one?
Make a prediction first and then find and uncheck this rule in Devtools */
body,
html {
padding: 0;
margin: 0;
}
/* Rules for interactive elements like links and buttons.
What happens when you change the order of these rules around? */
a,
a:any-link,
button {
color: currentColor;
text-decoration: none;
font-weight: bold;
transition: all 0.3s;
}
:focus {
outline: none;
}
a:hover,
a:focus,
button:hover,
button:focus {
color: var(--brand);
}
a:focus,
button:focus {
outline: 2px dashed var(--brand);
}
button {
grid-area: button;
appearance: none;
border: none;
background: transparent;
}
/* This is a "reset" rule. Google this idea. */
ul,
ul li {
list-style: none;
margin: 0;
padding: 0;
}
/* LAYOUT
Set up the body rules: fonts, colours, and spacing.
Everything inside the body will inherit these basic styles
*/
body {
font: 100%/1.5 var(--copy), system-ui, sans-serif;
background-color: var(--paper);
color: var(--ink);
/* Let's also write a layout for the whole site. */
display: grid;
gap: var(--space);
grid-template:
". ...... ." var(--space)
". header ." min-content
". main ." minmax(75vh, 1fr)
". footer ." min-content
". ...... ." var(--space) /
minmax(var(--space), 1fr) var(--container) minmax(var(--space), 1fr);
place-content: center;
}
/* Now let's add each component to this grid layout
And give them their own layouts inside. */
header {
grid-area: header;
display: grid;
grid-template:
"logo space button" var(--finger) /
var(--finger) 1fr var(--finger);
}
header h1 {
grid-area: logo;
margin: 0;
}
main {
grid-area: main;
display: flex;
flex-flow: row wrap;
gap: var(--space);
}
main h2 {
width: 100%;
text-align: center;
font-size: 2em;
}
footer {
grid-area: footer;
display: grid;
grid-template: "github space" var(--finger) / var(--finger) 1fr;
}
footer a {
grid-area: github;
}
/* This is the most complicated one!
How will you write yours? */
.menu {
background-color: var(--ink);
color: var(--paper);
height: 100vh;
width: max-content;
padding: var(--space);
z-index: 1;
position: absolute;
left: -100vw;
}
.menu.is-active {
left: 0;
}
/* Now inside main we have a deck/list/array we can stuff some objects in */
.deck {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(var(--box), 1fr));
gap: var(--space);
flex-grow: 1;
}
/* This time we will fill this with cards.
You will write a lot of card components as a developer.
Every time you look at a website, find the cards and inspect them in Devtools
to see how they are made. Notice how my cards don't have a size. */
.card {
background-color: var(--paper);
padding: var(--space);
box-shadow: 2px 4px 16px var(--shade);
display: flex;
flex-flow: column-reverse;
align-items: center;
}
.card:hover,
.card:focus {
box-shadow: 1px 1px 2px var(--shade);
}
.emoji {
font-size: clamp(64px, calc(64px + 5vw), 144px);
}
/* Now some body copy.
Why have I constrained this box? Google it! */
.copy {
max-width: var(--line-length);
}
.copy p:first-of-type::first-letter {
initial-letter: 2;
margin: 0 0.5ch 0 0;
padding: 0.5ch;
background-color: var(--brand);
color: var(--paper);
}
/* Now some states
Why are these things invisible?
What is this for and why did we not use display:none? */
.is-invisible {
position: absolute;
left: -100vw;
}
.is-invisible:focus {
left: 0;
}