diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-11-14 15:40:31 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-12-05 15:59:40 +0100 |
| commit | a4e5e074ac0dfb478c362af2dc37a9e333d86547 (patch) | |
| tree | 02216845f2e0a1d023c7212608e8d10410a2b19c | |
| parent | 13b2156c68aa8e6565923dfad336461a393b75fa (diff) | |
| download | rust-a4e5e074ac0dfb478c362af2dc37a9e333d86547.tar.gz rust-a4e5e074ac0dfb478c362af2dc37a9e333d86547.zip | |
Make headings anchor hidden by default and show on hover
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 22fe5d8b0cf..52af572f770 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -765,14 +765,30 @@ nav.sub { h2.section-header > .anchor { padding-right: 6px; } -.doc-anchor { - margin-right: 6px; +a.doc-anchor { + color: var(--main-color); + display: none; + position: absolute; + left: -17px; + /* 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; +} +/* If the first element of the top doc block is a heading, we don't want to ever display its anchor +because of the `[-]` element which would overlap with it. */ +.top-doc > .docblock > *:first-child > .doc-anchor { + display: none !important; } .main-heading a:hover, .example-wrap .rust a:hover, .all-items a:hover, -.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, +.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover:not(.doc-anchor), .docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, .item-info a { text-decoration: underline; |
