From 39f2d25090e4b61a695fb6d72113689dcf2ae724 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 18 Mar 2024 08:56:12 -0700 Subject: [PATCH] Fix heading anchors in doc pages. --- src/doc/rust.css | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/doc/rust.css b/src/doc/rust.css index bd2e0b9451870..9e51f03085fb8 100644 --- a/src/doc/rust.css +++ b/src/doc/rust.css @@ -136,6 +136,28 @@ h1 a:link, h1 a:visited, h2 a:link, h2 a:visited, h3 a:link, h3 a:visited, h4 a:link, h4 a:visited, h5 a:link, h5 a:visited {color: black;} +h1, h2, h3, h4, h5 { + /* This is needed to be able to position the doc-anchor. Ideally there + would be a
around the whole document, but we don't have that. */ + position: relative; +} + +a.doc-anchor { + color: black; + display: none; + position: absolute; + left: -20px; + /* We add this padding so that when the cursor moves from the heading's text to the anchor, + the anchor doesn't disappear. */ + padding-right: 5px; + /* And this padding is used to make the anchor larger and easier to click on. */ + padding-left: 3px; +} +*:hover > .doc-anchor { + display: block; +} + + /* Code */ pre, code {