@@ -159,6 +159,16 @@ dfn {
159159 font-size : 0.8em ;
160160}
161161
162+ /* included in the grid below as 20px */
163+ .page , .content {
164+ padding-left : 0 ;
165+ padding-right : 0 ;
166+ }
167+ /* required to accomodate above, somehow... */
168+ # menu-bar {
169+ margin-left : 0 ;
170+ }
171+
162172main {
163173 /* To nicely display rules (`[a.b.c]`) on a side of the main text body we
164174 use grid layout. */
@@ -170,6 +180,10 @@ main {
170180 [text] auto
171181 /* Right margin */
172182 [margin] minmax (20px , 1fr );
183+
184+ /* We do these by hand via the grid */
185+ margin : 0 ;
186+ padding : 0 !important ;
173187 max-width : none !important ;
174188}
175189
@@ -190,13 +204,65 @@ main > .rule {
190204 grid-column : rules;
191205}
192206
207+ /* This is quite dumb, ugh.
208+ CSS doesn't allow margin colapsing between grid items and anything else
209+ (src: <https://stackoverflow.com/a/37837971>), which means that the margins
210+ of li's children are not collapsed with ul's margins, adding too much margins.
211+
212+ Ideally we'd add `<div>`s for each grid cell, so that margin collapsing happens
213+ as-usual inside of them. But, we don't have that kind of control over mdbook. */
214+ main > ul > li > * : first-child ,
215+ main > ul > li > pre : first-child > pre .playground {
216+ margin-top : 0 ;
217+ }
218+ main > ul > li > * : last-child ,
219+ main > ul > li > pre : last-child > pre .playground {
220+ margin-bottom : 0 ;
221+ }
222+
223+ /* Similarly to the above, margin collapse doesn't happen between grid items,
224+ so we have to replace it with grid gap. (p, pre, and ul had 16px vertical margins) */
225+ main {
226+ row-gap : 16px ;
227+ }
228+ main > p ,
229+ main > pre ,
230+ main > pre > pre .playground ,
231+ main > ul {
232+ margin-top : 0 ;
233+ margin-bottom : 0 ;
234+ }
235+
236+ /* Values for h2/h3/h4 margin-top and blockquote margin are taken from mdbook's general.css,
237+ values for h2/h3/h4 margin-bottom are taken from <https://www.w3schools.com/cssref/css_default_values.php> */
238+ main > h2 {
239+ margin-top : calc (2.5em - 16px );
240+ margin-bottom : calc (0.83em - 16px );
241+ }
242+ main > h3 {
243+ margin-top : calc (2.5em - 16px );
244+ margin-bottom : calc (1em - 16px );
245+ }
246+ main > h4 {
247+ margin-top : calc (2em - 16px );
248+ margin-bottom : calc (1.33em - 16px );
249+ }
250+ main > blockquote {
251+ margin-top : calc (20px - 16px );
252+ margin-bottom : calc (20px - 16px );
253+ }
254+
193255main > .rule {
194256 max-width : unset;
195257 justify-self : right;
196258 width : 100% ;
197259}
198260
199261.rule-link {
262+ float : right;
263+ text-align : right;
264+ padding-right : 10px ;
265+ /* Remove the blue coloring of links on rules that mdbook normally sets. */
200266 color : # 999 !important ;
201267}
202268
0 commit comments