Skip to content

Commit ce5b141

Browse files
committed
Align case study images with subgrid
1 parent d1f21e2 commit ce5b141

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

‎assets/css/casestudies.css‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,54 @@
99
font-size: 27px;
1010
}
1111

12+
/* Lets the card grid below adapt to the width of this column of the page. */
13+
.casestudies > .container {
14+
container-type: inline-size;
15+
}
16+
17+
/* Cards share title / image / text rows via subgrid, so images line up however
18+
a translated title wraps; `1fr` text rows keep the cards the same height. */
1219
.casestudies-box-container {
13-
display: flex;
14-
flex-wrap: wrap;
15-
justify-content: center;
20+
display: grid;
21+
grid-template-columns: repeat(auto-fit, minmax(min(275px, 100%), 350px));
22+
grid-auto-rows: auto auto 1fr;
23+
justify-content: space-around;
1624
}
1725

1826
.casestudies-box-content {
19-
height: 450px;
20-
min-width: 275px;
21-
width: 350px;
22-
margin: 30px auto;
27+
display: grid;
28+
grid-row: span 3;
29+
grid-template-rows: subgrid;
30+
margin: 30px 0;
2331
border-radius: 3px;
2432
}
2533

34+
/* With room for three 350px columns, centre a card left alone on the last row. */
35+
@container (min-width: 1050px) {
36+
.casestudies-box-content:last-child:nth-child(3n + 1) {
37+
grid-column: 2;
38+
}
39+
}
40+
2641
.casestudies-box-title {
27-
line-height: 1.5em;
28-
height: 3.0em;
2942
margin: 15px;
3043
font-size: 16px;
3144
text-transform: uppercase;
3245
}
3346

47+
/* Same shape for every image, whatever the aspect ratio of the file. */
3448
.casestudies-box-content img {
49+
width: 100%;
50+
aspect-ratio: 8 / 5;
3551
object-fit: cover;
36-
width: 350px;
37-
height: 218.5px;
3852
}
3953

4054
.casestudies-box-text {
4155
margin: 30px 15px;
4256
font-size: 14px;
4357
}
4458

45-
@media only screen and (max-width: 1300px) {
46-
.casestudies-box-container {
47-
justify-content: center;
48-
}
49-
}
50-
51-
@media only screen and (min-width: 600px) and (max-width: 700px) {
52-
.casestudies-box-container {
53-
flex-direction: column;
54-
align-items: center;
55-
}
56-
}
57-
5859
.casestudies-underline {
59-
display: inline-block;
6060
-webkit-transform: perspective(1px) translateZ(0);
6161
transform: perspective(1px) translateZ(0);
6262
border: .02em solid var(--pst-color-border);

0 commit comments

Comments
 (0)