Skip to content

Commit 7526236

Browse files
Make headings anchor hidden by default and show on hover
1 parent a14678f commit 7526236

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/librustdoc/html/static/css/rustdoc.css

+12-5
Original file line numberDiff line numberDiff line change
@@ -768,23 +768,30 @@ nav.sub {
768768
h2.small-section-header > .anchor {
769769
padding-right: 6px;
770770
}
771-
.doc-anchor {
771+
a.doc-anchor {
772772
color: var(--main-color);
773773
display: none;
774774
position: absolute;
775-
left: -6px;
775+
left: -17px;
776+
/* We add this padding so that when the cursor moves from the heading's text to the anchor,
777+
the anchor doesn't disappear. */
778+
padding-right: 5px;
779+
/* And this padding is used to make the anchor larger and easier to click on. */
780+
padding-left: 3px;
776781
}
777782
*:hover > .doc-anchor {
778783
display: block;
779784
}
780-
#top-doc > *:first-child > .doc-anchor {
781-
display: none;
785+
/* If the first element of the top doc block is a heading, we don't want to ever display its anchor
786+
because of the `[-]` element which would overlap with it. */
787+
.top-doc > .docblock > *:first-child > .doc-anchor {
788+
display: none !important;
782789
}
783790

784791
.main-heading a:hover,
785792
.example-wrap .rust a:hover,
786793
.all-items a:hover,
787-
.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,
794+
.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover:not(.doc-anchor),
788795
.docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,
789796
.item-info a {
790797
text-decoration: underline;

0 commit comments

Comments
 (0)