WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
226819
Inaccurate background-size with ch units
https://bugs.webkit.org/show_bug.cgi?id=226819
Summary
Inaccurate background-size with ch units
Gabor Vajda
Reported
2021-06-09 08:06:37 PDT
Created
attachment 430966
[details]
Inaccurate background layout in Safari The issue is demonstrated here:
https://codepen.io/vajdagabor/pen/VwpBRQG
I'm trying to create a (monospace) code display with repeated background pattern, where background-image is positioned precisely to every character. Setting background-size with ch unit would be ideal, but the result is inaccurate on Safari. The example works well on Chrome and Firefox. Also, the pattern in the example is not visible when the font is small. This is the CSS: pre { background-image: linear-gradient(to right, black 0%, black 1px, transparent 1px, transparent 100%); background-size: 1ch; }
Attachments
Inaccurate background layout in Safari
(158.95 KB, image/png)
2021-06-09 08:06 PDT
,
Gabor Vajda
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2021-06-16 08:07:17 PDT
<
rdar://problem/79398089
>
hi
Comment 2
2024-12-26 07:38:02 PST
Added some examples, since I'd love to see WebKit catch up on this.
https://codepen.io/valler/pen/dPbzPgG?editors=1100
a) shows a flexbox which demos an actual row major layout with alternating background colors for rows. Ideally B to F should all match A when it comes to rendering the background, and box sizes also should match for A to D. b) inline content with known width given in relative units `ch` and hardcoded background gradient stops. c) inline content set to max-content and repeating gradient given as percentage of expected width. d) inline content set to max-content and repeating gradient given in relative units `ch`. e) inline content with its width truncated to the nearest relative unit `ch` using `round()` and a repeating gradient given in relative units `ch`. f) full width inline content with a repeating gradient given in relative units `ch`. Declaring background sizes and gradient stops in the same units as the box size with - big, clearly visible - discrepancies is unfortunate (none of C to F are close to A or B).
hi
Comment 3
2024-12-26 07:53:36 PST
*A is a column major layout, not row major (sry for the noise).
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug