@@ -156,31 +156,46 @@ dfn {
156
156
157
157
/* Rules are generated via r[foo.bar] syntax, processed by mdbook-spec. */
158
158
.rule {
159
- /* Allows the rule to be positioned. */
160
- position : relative;
161
- /* Position slightly to the left. */
162
- left : -4em ;
163
- color : # 999 ;
164
159
font-size : 0.8em ;
165
160
}
166
- /* mdbook will wrap the rule content in a <p> tag, with a margin. However, we
167
- don't need the extra space
168
- */
169
- .rule ~ p {
170
- margin-top : 0px ;
161
+
162
+ main {
163
+ /* To nicely display rules (`[a.b.c]`) on a side of the main text body we
164
+ use grid layout. */
165
+ display : grid;
166
+ grid-template-columns :
167
+ /* Left margin / place for rules */
168
+ [rules] minmax (20px , 1fr )
169
+ /* The main text body */
170
+ [text] auto
171
+ /* Right margin */
172
+ [margin] minmax (20px , 1fr );
173
+ max-width : none !important ;
171
174
}
172
175
173
- /* When the sidebar is visible, reduce the spacing of rules so that the
174
- content doesn't get shifted too far, and make the text too narrow.
175
- */
176
- .sidebar-visible .rule {
177
- left : -1em ;
176
+ main > * {
177
+ /* By default grid items can't be smaller than their content.
178
+ That is, by default `min-width: auto`.
179
+ We want to be able to force code blocks to be scrollable,
180
+ so we need to overwrite `min-width`. */
181
+ min-width : 0 ;
182
+ max-width : var (--content-max-width );
183
+
184
+ /* All elements should be in the main text body... */
185
+ grid-column : text;
186
+ }
187
+
188
+ main > .rule {
189
+ /* ... except the rules, which must be in the left margin */
190
+ grid-column : rules;
178
191
}
179
- .sidebar-visible .content main {
180
- padding-left : 1em ;
192
+
193
+ main > .rule {
194
+ max-width : unset;
195
+ justify-self : right;
196
+ width : 100% ;
181
197
}
182
198
183
- /* Remove the blue coloring of links on rules that mdbook normally sets. */
184
199
.rule-link {
185
200
color : # 999 !important ;
186
201
}
0 commit comments