diff --git a/ts/a11y/explorer.ts b/ts/a11y/explorer.ts index 7964807c0..3fe4ae6e1 100644 --- a/ts/a11y/explorer.ts +++ b/ts/a11y/explorer.ts @@ -380,9 +380,9 @@ export function ExplorerMathDocumentMixin< }, 'mjx-container > mjx-help': { display: 'none', - position: 'absolute', - top: '-.33em', - right: '-.5em', + position: 'sticky', + inset: '-100% 0 100% 0', + margin: '-.3em -.5em 0 -.1em', width: '.6em', height: '.6em', cursor: 'pointer', diff --git a/ts/output/common.ts b/ts/output/common.ts index 23e04e865..4f6ce8377 100644 --- a/ts/output/common.ts +++ b/ts/output/common.ts @@ -167,8 +167,8 @@ export abstract class CommonOutputJax< display: 'block', 'text-align': 'center', 'justify-content': 'center', - margin: 'calc(1em - 2px) 0', - padding: '2px 0', + margin: '.7em 0', + padding: '.3em 2px', }, 'mjx-container[display][width="full"]': { display: 'flex', @@ -374,7 +374,8 @@ export abstract class CommonOutputJax< this.math.display ) { const w = wrapper.getOuterBBox().w; - const W = this.math.metrics.containerWidth / this.pxPerEm; + const W = + Math.max(0, this.math.metrics.containerWidth - 4) / this.pxPerEm; if (w > W && w) { scale *= W / w; }