Skip to content

Centre the back-to-top arrow in its button - #353

Merged
puikinsh merged 1 commit into
masterfrom
fix/back-to-top-centering
Aug 11, 2026
Merged

Centre the back-to-top arrow in its button#353
puikinsh merged 1 commit into
masterfrom
fix/back-to-top-centering

Conversation

@puikinsh

Copy link
Copy Markdown
Member

The up arrow in <a class="btn btn-sm fade-half back-to-top inner-link"> sat off-centre.

Cause

The button is a fixed 36px box. After .btn's 2px border and .back-to-top's 5px 11px padding the content box is 22px tall and 10px wide — but the glyph is 18px, carrying a 27px line box inherited from .btn-sm.

Neither axis could centre: the line box overflows vertically, and an 18px glyph cannot centre inside a 10px content box.

Glyph ink measured relative to the button centre:

dx dy
before +2.75px −1.88px
after −0.12px +0.12px

Fix

Centred with flex rather than padding + line-height arithmetic, so it no longer depends on the glyph's metrics happening to match the box.

letter-spacing is reset too — .btn adds 1px after every character including the last, which offsets any centred single glyph by half that, and was part of the horizontal error.

.screen-reader-text was checked and ruled out: it is position: absolute, so it never participated in the line box.

The button is a fixed 36px box. With .btn's 2px border and .back-to-top's
5px/11px padding, the content box was 22px tall and 10px wide -- while the
glyph is 18px carrying a 27px line box inherited from .btn-sm. Neither axis
could centre: the line box overflowed vertically, and an 18px glyph cannot
centre in a 10px content box.

Measured on the rendered button, glyph ink relative to the button centre:

    before   dx +2.75px   dy -1.88px
    after    dx -0.12px   dy +0.12px

Centred with flex instead of padding + line-height arithmetic, so it no longer
depends on the glyph's metrics matching the box. letter-spacing is also reset:
.btn adds 1px after every character including the last, which offsets any
centred single glyph by half that.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@puikinsh
puikinsh merged commit fbf1e88 into master Aug 11, 2026
10 checks passed
@puikinsh
puikinsh deleted the fix/back-to-top-centering branch August 11, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant