Skip to content

Commit 39f2d25

Browse files
committed
Fix heading anchors in doc pages.
1 parent 3cdcdaf commit 39f2d25

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/doc/rust.css

+22
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ h1 a:link, h1 a:visited, h2 a:link, h2 a:visited,
136136
h3 a:link, h3 a:visited, h4 a:link, h4 a:visited,
137137
h5 a:link, h5 a:visited {color: black;}
138138

139+
h1, h2, h3, h4, h5 {
140+
/* This is needed to be able to position the doc-anchor. Ideally there
141+
would be a <div> around the whole document, but we don't have that. */
142+
position: relative;
143+
}
144+
145+
a.doc-anchor {
146+
color: black;
147+
display: none;
148+
position: absolute;
149+
left: -20px;
150+
/* We add this padding so that when the cursor moves from the heading's text to the anchor,
151+
the anchor doesn't disappear. */
152+
padding-right: 5px;
153+
/* And this padding is used to make the anchor larger and easier to click on. */
154+
padding-left: 3px;
155+
}
156+
*:hover > .doc-anchor {
157+
display: block;
158+
}
159+
160+
139161
/* Code */
140162

141163
pre, code {

0 commit comments

Comments
 (0)