Skip to content

Commit 36e8936

Browse files
authored
Merge pull request #608 from ernestofgonzalez/align-cs-titles
Align images for multiline titles in CS section
2 parents b30aa5c + ce5b141 commit 36e8936

2 files changed

Lines changed: 30 additions & 22 deletions

File tree

‎assets/css/casestudies.css‎

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +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 {
2742
margin: 15px;
2843
font-size: 16px;
2944
text-transform: uppercase;
3045
}
3146

47+
/* Same shape for every image, whatever the aspect ratio of the file. */
48+
.casestudies-box-content img {
49+
width: 100%;
50+
aspect-ratio: 8 / 5;
51+
object-fit: cover;
52+
}
53+
3254
.casestudies-box-text {
3355
margin: 30px 15px;
3456
font-size: 14px;
3557
}
3658

37-
@media only screen and (max-width: 1300px) {
38-
.casestudies-box-container {
39-
justify-content: center;
40-
}
41-
}
42-
43-
@media only screen and (min-width: 600px) and (max-width: 700px) {
44-
.casestudies-box-container {
45-
flex-direction: column;
46-
align-items: center;
47-
}
48-
}
49-
5059
.casestudies-underline {
51-
display: inline-block;
5260
-webkit-transform: perspective(1px) translateZ(0);
5361
transform: perspective(1px) translateZ(0);
5462
border: .02em solid var(--pst-color-border);

‎layouts/partials/casestudies.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1 id="case-studies" class="casestudies-title">{{ $title }}</h1>
88
{{- range $features }}
99
<a class="casestudies-box-content casestudies-underline" href="{{ .url }}">
1010
<div class="casestudies-box-title">{{ .title }}</div>
11-
<img src="{{ .img }}" alt="{{ .alttext }}">
11+
<img src="{{ .img }}" alt="{{ .alttext }}">
1212
<div class="casestudies-box-text">{{ .text | markdownify }}</div>
1313
</a>
1414
{{- end }}

0 commit comments

Comments
 (0)