Skip to content

Commit f8c49c8

Browse files
alphapapastefanv
andauthored
Fix: (posts, shortcuts) Adjust width, padding for narrower screens (#402)
* Tidy: Consolidate .content-container rules * Comment: Add FIXME * Fix: (_base.scss) PRE wrapping and breaking This solves a very non-obvious problem in that a single PRE element that happens to have a long line or long words, even when the OVERFLOW property is set to constrain the element, can cause the whole page layout to break, even when using FLEX, because the browser seems to use the ideal width of the element (as if there were enough screen width to display it without any overflow or wrapping) to calculate minimum width of the parent elements rather than the constrained width of the element. * Fix: .content-container and #shortcuts-container flexing After solving the issue with the PRE wrapping and breaking, which was obscuring the problem, these remaining fixes are straightforward. * Simplify shortcuts layout using flex and breakpoints * Allow code cells overflowing into parent Remove media selector that flows shortcuts to bottom, since we hide shortcuts at the same time. * Undo changes to pst * Fix blog responsive layout --------- Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
1 parent 78c773a commit f8c49c8

8 files changed

Lines changed: 34 additions & 55 deletions

File tree

assets/theme-css/content.css

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
.content-padding {
22
display: flex;
3+
flex-wrap: nowrap;
34
justify-content: center;
45
margin: 1em;
56
}
67

78
.content-container {
8-
max-width: 850px;
9+
flex-basis: 70em;
10+
flex-shrink: 1;
11+
flex-direction: column;
912
margin: 0 30px;
10-
overflow: hidden;
11-
}
1213

13-
.content-container .divider {
14-
height: 3px;
15-
border-radius: 50px;
16-
background: var(--pst-color-text-base);
17-
width: 60px;
18-
&.is-centered {
19-
margin: 0 auto;
20-
}
14+
/* Handle code cells overflowing */
15+
overflow: auto;
2116
}

assets/theme-css/posts.css

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
div.post-list {
2-
clear: left;
1+
.post-list {
2+
display: flex;
3+
flex-wrap: wrap;
4+
column-gap: 2rem;
5+
}
6+
7+
.post-list article {
8+
flex-grow: 2;
9+
flex-basis: 48%;
10+
padding-top: 1.5rem;
311
}
412

513
.post-title a {
@@ -11,10 +19,6 @@ div.post-list {
1119
color: var(--pst-color-text-muted);
1220
}
1321

14-
.post-list article {
15-
padding-top: 1.5rem;
16-
}
17-
1822
.post-list .post-title {
1923
font-size: 1.25rem;
2024
font-weight: bold;
@@ -79,10 +83,11 @@ div.MathJax_Display {
7983

8084
.post-featuredImage img {
8185
/* FIXME: Use color variable. */
82-
border: 0.15em #bbb solid;
83-
border-radius: 25px;
86+
border: 1px #bbb solid;
8487
max-width: 20rem;
8588
margin: 0.5em;
89+
float: left;
90+
margin-right: 1.25rem;
8691
}
8792

8893
.read-more {
@@ -103,30 +108,3 @@ div.MathJax_Display {
103108
margin-top: 60px;
104109
padding-bottom: 10px;
105110
}
106-
107-
.content-container .post-list {
108-
display: flex;
109-
flex-wrap: wrap;
110-
column-gap: 2rem;
111-
}
112-
113-
/* Default: single column layout for mobile */
114-
.content-container {
115-
max-width: 70em;
116-
margin: 0 30px;
117-
flex-direction: column;
118-
}
119-
120-
/* Full screen two-column layout for desktop etc. */
121-
@media only screen and (min-width: 75em) {
122-
.content-container {
123-
min-width: 70rem;
124-
flex-direction: row;
125-
}
126-
127-
article {
128-
flex-grow: 1;
129-
flex-shrink: 0;
130-
flex-basis: calc(50% - 1rem);
131-
}
132-
}

assets/theme-css/shortcuts.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
position: sticky;
33
align-self: flex-start;
44
top: 5rem;
5-
width: 100%;
6-
max-width: 150px;
5+
flex-basis: 15em;
6+
/* We disable shrinking for this container, otherwise the single-line
7+
items start wrapping to two lines, especially when active and
8+
bolded, which causes distracting layout changes. */
9+
flex-shrink: 0;
710
}
811

912
#shortcuts {
@@ -46,7 +49,8 @@
4649
cursor: pointer;
4750
}
4851

49-
@media only screen and (max-width: 1090px) {
52+
/* Same breakpoint as burger menu */
53+
@media screen and (max-width: 1023px) {
5054
#shortcuts-container {
5155
display: none;
5256
}

layouts/_default/section.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<section class="section content-padding flex-row">
2+
<section class="section content-padding">
33
<div class="content-container">
44
{{ partial "breadcrumbs.html" . }}
55
<h1>{{ .Title }}</h1>

layouts/_default/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<section class="article content-padding flex-row">
2+
<section class="article content-padding">
33
<div class="content-container">
44
{{ partial "breadcrumbs.html" . }}
55
<h1>{{ .Title }}</h1>

layouts/partials/posts/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="section content-padding flex-row">
1+
<section class="section content-padding">
22
<div class="tag-cloud is-hidden-mobile">
33
<h2 class="tag-cloud-title">{{ i18n "tags" }}</h2>
44
{{ if not (eq (len $.Site.Taxonomies.tags) 0) }}

layouts/partials/posts/post.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $featuredImage := .Resources.GetMatch "featuredImage" -}}
2-
<section class="post content-padding flex-row">
2+
<section class="post content-padding">
33
<div class="content-container">
44
{{ partial "breadcrumbs.html" . }}
55
<h1>{{ .Title }}</h1>
@@ -9,7 +9,9 @@ <h5 class="subtitle">{{ .Params.Subtitle }}</h5>
99
<div class="post-meta">{{ partial "posts/meta.html" . }}</div>
1010
<div class="post-content">
1111
{{ with $featuredImage }}
12-
<img src="{{ .RelPermalink }}" {{ if .Params.description }}alt="{{ .Params.description }}"{{ end }}/>
12+
<div class="post-featuredImage">
13+
<img src="{{ .RelPermalink }}" {{ if .Params.description }}alt="{{ .Params.description }}"{{ end }}/>
14+
</div>
1315
{{ end }}
1416
{{ .Content }}
1517
</div>

layouts/partials/section/section.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="content-padding flex-row">
1+
<section class="content-padding">
22
<div class="content-container">
33
{{ partial "breadcrumbs.html" . }}
44
<h1>{{ .Title }}</h1>

0 commit comments

Comments
 (0)