🜃 CSS Hover Footnote
The trick behind the footnotes on this site and the hover previews in notes like Colour Theory is the same adjacent-hover pattern, just with different content in the hidden span. It's AetherAnne's pattern for footnotes without JavaScript, wired through markdown-it's renderer overrides here instead of hand-written HTML:
.fn-wrapper {
position: relative;
display: inline-block;
}
.fn-content {
display: none;
position: absolute;
bottom: 100%;
left: 0;
max-width: 30ch;
}
.fn-wrapper:hover .fn-content,
.fn-wrapper:focus-within .fn-content {
display: block;
}
The reference and the hidden content are wrapped in one position: relative span. .fn-content needs a positioned ancestor to anchor position: absolute against, and same-level siblings don't count.
See Symbol Taxonomy for other design patterns, and Transclusion for the other place this hover pattern is reused.
- Links to
- the footnotes on this site · Colour Theory · Symbol Taxonomy · Transclusion
- Linked from
- Transclusion · Colour Theory · Symbol Taxonomy · Values