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 */
1+ .page-header {
2+ display : flex;
3+ flex-direction : column;
4+ align-items : center;
5+ justify-content : center;
6+ text-align : center;
7+ min-height : 300px ;
8+ background-color : # f4f4f4 ;
9+ }
10+
11+ .page-header h1 {
12+ margin-bottom : 10px ;
13+ }
614
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 ====== */
1915: root {
2016 --paper : oklch (7 0 0 );
2117 --ink : color-mix (in oklab, var (--color ) 5% , black);
@@ -24,8 +20,7 @@ As well as useful links to learn more */
2420 --line : 1px solid;
2521 --container : 1280px ;
2622}
27- /* ====== Base Elements ======
28- General rules for basic HTML elements in any context */
23+
2924body {
3025 background : var (--paper );
3126 color : var (--ink );
4136 width : 100% ;
4237 object-fit : cover;
4338}
44- /* ====== Site Layout ======
45- Setting the overall rules for page regions
46- https://www.w3.org/WAI/tutorials/page-structure/regions/
47- */
48- main {
39+
40+ .main-wrapper {
4941 max-width : var (--container );
5042 margin : 0 auto calc (var (--space ) * 4 ) auto;
5143}
@@ -54,36 +46,51 @@ footer {
5446 bottom : 0 ;
5547 text-align : center;
5648}
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 {
49+
50+ .main-wrapper {
6551 display : grid;
6652 grid-template-columns : 1fr 1fr ;
6753 gap : var (--space );
6854 > * : first-child {
6955 grid-column : span 2 ;
7056 }
7157}
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- */
58+
7759article {
7860 border : var (--line );
7961 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 ;
85- }
86- > img {
87- grid-column : span 3 ;
88- }
62+ display : flex;
63+ flex-direction : column;
64+
65+ height : 100% ;
66+
67+ padding : 0 var (--space ) var (--space ) var (--space );
68+
69+ overflow : hidden;
70+ }
71+
72+ article img {
73+ width : calc (100% + (var (--space ) * 2 ));
74+ margin-left : calc (var (--space )* -1 );
75+ height : 250px ;
76+ object-fit : cover;
77+ margin-bottom : var (--space );
78+ }
79+
80+ article h2 {
81+ min-height : 5em ;
82+ display : flex;
83+ align-items : center; /* Vertically centers the text if it's only one line */
84+ margin-top : 0 ;
85+ margin-bottom : var (--space );
86+ }
87+
88+ article p {
89+ flex-grow : 1 ;
90+ margin-bottom : var (--space );
91+ }
92+
93+ article a {
94+ margin-top : auto;
95+ align-self : flex-start;
8996}
0 commit comments