|
1 | | -/* Here are some starter styles |
2 | | -You can edit these or replace them entirely |
3 | | -It's showing you a common way to organise CSS |
4 | | -And includes solutions to common problems |
5 | | -As well as useful links to learn more */ |
6 | | - |
7 | | -/* ====== Design Palette ====== |
8 | | - This is our "design palette". |
9 | | - It sets out the colours, fonts, styles etc to be used in this design |
10 | | - At work, a designer will give these to you based on the corporate brand, but while you are learning |
11 | | - You can design it yourself if you like |
12 | | - Inspect the starter design with Devtools |
13 | | - Click on the colour swatches to see what is happening |
14 | | - I've put some useful CSS you won't have learned yet |
15 | | - For you to explore and play with if you are interested |
16 | | - https://web.dev/articles/min-max-clamp |
17 | | - https://scrimba.com/learn-css-variables-c026 |
18 | | -====== Design Palette ====== */ |
19 | 1 | :root { |
20 | | - --paper: oklch(7 0 0); |
21 | | - --ink: color-mix(in oklab, var(--color) 5%, black); |
22 | | - --font: 100%/1.5 system-ui; |
23 | | - --space: clamp(6px, 6px + 2vw, 15px); |
24 | | - --line: 1px solid; |
25 | | - --container: 1280px; |
| 2 | + --space: 1rem; |
| 3 | + --container: 1100px; |
| 4 | + --border: 1px solid #000; |
| 5 | +} |
| 6 | + |
| 7 | +* { |
| 8 | + box-sizing: border-box; |
26 | 9 | } |
27 | | -/* ====== Base Elements ====== |
28 | | - General rules for basic HTML elements in any context */ |
| 10 | + |
29 | 11 | body { |
30 | | - background: var(--paper); |
31 | | - color: var(--ink); |
32 | | - font: var(--font); |
| 12 | + margin: 0; |
| 13 | + padding-bottom: 80px; |
| 14 | + font-family: Arial, Helvetica, sans-serif; |
33 | 15 | } |
34 | | -a { |
35 | | - padding: var(--space); |
36 | | - border: var(--line); |
37 | | - max-width: fit-content; |
| 16 | + |
| 17 | +header { |
| 18 | + text-align: center; |
| 19 | + padding: 2rem 1rem; |
38 | 20 | } |
39 | | -img, |
40 | | -svg { |
41 | | - width: 100%; |
42 | | - object-fit: cover; |
| 21 | + |
| 22 | +header h1 { |
| 23 | + margin-bottom: 0.5rem; |
43 | 24 | } |
44 | | -/* ====== Site Layout ====== |
45 | | -Setting the overall rules for page regions |
46 | | -https://www.w3.org/WAI/tutorials/page-structure/regions/ |
47 | | -*/ |
| 25 | + |
48 | 26 | main { |
49 | 27 | max-width: var(--container); |
50 | | - margin: 0 auto calc(var(--space) * 4) auto; |
| 28 | + margin: 0 auto; |
| 29 | + display: grid; |
| 30 | + grid-template-columns: 1fr 1fr; |
| 31 | + gap: 1.5rem; |
| 32 | + padding: 1rem; |
| 33 | +} |
| 34 | + |
| 35 | +main article:first-child { |
| 36 | + grid-column: 1 / 3; |
| 37 | +} |
| 38 | + |
| 39 | +article { |
| 40 | + border: var(--border); |
| 41 | + display: grid; |
| 42 | + grid-template-columns: 1rem 1fr 1rem; |
| 43 | + padding-bottom: 1rem; |
| 44 | +} |
| 45 | + |
| 46 | +article > * { |
| 47 | + grid-column: 2; |
51 | 48 | } |
| 49 | + |
| 50 | +article img { |
| 51 | + grid-column: 1 / 4; |
| 52 | + width: 100%; |
| 53 | + height: 250px; |
| 54 | + object-fit: cover; |
| 55 | + border-bottom: var(--border); |
| 56 | +} |
| 57 | + |
| 58 | +article h2 { |
| 59 | + margin-top: 1rem; |
| 60 | +} |
| 61 | + |
| 62 | +article a { |
| 63 | + display: inline-block; |
| 64 | + width: fit-content; |
| 65 | + text-decoration: none; |
| 66 | + color: black; |
| 67 | + border: var(--border); |
| 68 | + padding: 0.75rem 1rem; |
| 69 | +} |
| 70 | + |
52 | 71 | footer { |
53 | 72 | position: fixed; |
54 | 73 | bottom: 0; |
| 74 | + left: 0; |
| 75 | + width: 100%; |
55 | 76 | text-align: center; |
| 77 | + border-top: var(--border); |
| 78 | + background-color: white; |
| 79 | + padding: 1rem; |
56 | 80 | } |
57 | | -/* ====== Articles Grid Layout ==== |
58 | | -Setting the rules for how articles are placed in the main element. |
59 | | -Inspect this in Devtools and click the "grid" button in the Elements view |
60 | | -Play with the options that come up. |
61 | | -https://developer.chrome.com/docs/devtools/css/grid |
62 | | -https://gridbyexample.com/learn/ |
63 | | -*/ |
64 | | -main { |
65 | | - display: grid; |
66 | | - grid-template-columns: 1fr 1fr; |
67 | | - gap: var(--space); |
68 | | - > *:first-child { |
69 | | - grid-column: span 2; |
70 | | - } |
71 | | -} |
72 | | -/* ====== Article Layout ====== |
73 | | -Setting the rules for how elements are placed in the article. |
74 | | -Now laying out just the INSIDE of the repeated card/article design. |
75 | | -Keeping things orderly and separate is the key to good, simple CSS. |
76 | | -*/ |
77 | | -article { |
78 | | - border: var(--line); |
79 | | - padding-bottom: var(--space); |
80 | | - text-align: left; |
81 | | - display: grid; |
82 | | - grid-template-columns: var(--space) 1fr var(--space); |
83 | | - > * { |
84 | | - grid-column: 2/3; |
| 81 | + |
| 82 | +@media (max-width: 768px) { |
| 83 | + main { |
| 84 | + grid-template-columns: 1fr; |
85 | 85 | } |
86 | | - > img { |
87 | | - grid-column: span 3; |
| 86 | + |
| 87 | + main article:first-child { |
| 88 | + grid-column: auto; |
88 | 89 | } |
89 | 90 | } |
0 commit comments