Skip to content

Fit a box to the picture inside it in HTML - #47

Merged
HarryCordewener merged 2 commits into
mainfrom
claude/box-figure-fit-4or9e4
Oct 7, 2026
Merged

HarryCordewener merged 2 commits into
mainfrom
claude/box-figure-fit-4or9e4

Conversation

@HarryCordewener

@HarryCordewener HarryCordewener commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Requested by Grave · project thread

Before: in the browser, box(figure(...)) drew the picture touching the box's top border, with a band about a descender high under it and 1ch of padding on the left and right. Measured in Chromium for a double box: left 16.8px, top 0px, bottom 14.6px. A small picture also left the rest of the box's width empty.

After: the box fits the picture: 0px on every side, and the box is no wider than the picture (a large picture still shrinks to the layout's width).

How: .ms-figure-image gets vertical-align: top, so no line room is kept under it anywhere. The emitter marks a box whose body is a lone, unfloated Figure it will show as an image ms-box-picture, which has no padding, width: fit-content and a block image. A box with text, a floated figure, or a refused picture (art fallback) keeps its padding. The box padding is now var(--ms-pad, 1ch), and a Frame whose Padding is not 1 writes --ms-pad on its fieldset, so pad reaches the HTML (it was always 1ch). SharpMUSH's shell.css copies LayoutCss.Fixed, so the bump there carries the changed rules.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PQJ7GSkYEQFfHqmQDwxbg9

The figure's <img> sat on the text baseline, leaving a descender-high band
under it, and .ms-box padded only its sides, so the picture touched the top
border. Align the picture to the top of its line, give a bordered box's
lone-line picture the box padding above and below, and carry Frame.Padding
into the HTML as --ms-pad.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PQJ7GSkYEQFfHqmQDwxbg9
@HarryCordewener HarryCordewener self-assigned this Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: e38af36e-a2b0-4c07-abbf-a7881a835ff4
📥 Commits

Reviewing files that changed from the base of the PR and between 5af1044 and b636dba.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • MarkupString.Html/Emitters/LayoutHtml.cs
  • MarkupString.Html/LayoutCss.cs
  • MarkupString.Tests/Layout/BlockLayoutTests.cs
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Grave preferred the picture filling the box over even padding. A box whose
body is a lone picture on its own line is marked ms-box-picture: no padding,
and no wider than the picture.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PQJ7GSkYEQFfHqmQDwxbg9
@HarryCordewener HarryCordewener changed the title Sit a boxed picture evenly in its box in HTML Fit a box to the picture inside it in HTML Oct 7, 2026
@HarryCordewener
HarryCordewener merged commit e981179 into main Oct 7, 2026
6 checks passed
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.

2 participants