SVG in a button is given much larger size than in Chrome
Categories
(Core :: SVG, defect)
Tracking
()
| Webcompat Priority | P3 |
People
(Reporter: twisniewski, Unassigned)
References
()
Details
Attachments
(1 file)
|
182 bytes,
text/html
|
Details |
In the attached test-case, Firefox does not seem to limit the size of the <svg> element in the <button>, while Chromium and WebKit do. This is causing layout issues on waitbutwhy.com.
Comment 1•6 years ago
|
||
Two differences I can see:
- If I add
width="100%" height="100%"to thesvg, then Chrome resolves the width against the default replaced element size (300), whereas we resolve it against the containing block width. - It seems like the lack of
widthandheightattributes in Chrome causes the button to be sized as if it had no content (or if you addedwidth="0").
Comment 2•5 years ago
|
||
if I use without nesting element.
data:text/html,<!doctype html><svg viewBox="0 0 6 6"><circle r="3" cx="3" cy="3" fill="blue"></circle></svg>
I get a full huge blue circle for every browsers full viewport
but as soon as it is inside the button (Tom's test)
data:text/html,<!doctype html><button><svg viewBox="0 0 6 6"><circle r="3" cx="3" cy="3" fill="blue"></circle></svg></button>
Big blue disc inside a button in Firefox
Disc not visible in Safari and Blink
Now if I use a simple div
data:text/html,<!doctype html><div><svg viewBox="0 0 6 6"><circle r="3" cx="3" cy="3" fill="blue"></circle></svg></div>
Then the 3 browsers have the same behavior.
Big blue disc full viewport
BUT if I add display:inline-block
data:text/html,<!doctype html><div style="display:inline-block"><svg viewBox="0 0 6 6"><circle r="3" cx="3" cy="3" fill="blue"></circle></svg></div>
Safari and Blink browsers the blue disc disappears, exactly like the button.
And for display: flex
data:text/html,<!doctype html><div style="display:flex"><svg viewBox="0 0 6 6"><circle r="3" cx="3" cy="3" fill="blue"></circle></svg></div>
Firefox and Chrome shows a big blue disc
Safari doesn't show the disc
So I have the feeling that the difference is due to inline-block context. button is an inline-block in the UA CSS.
That looks very close to all these different behaviors about SVG intrinsic sizing and viewbox and their relative contexts.
This has a lot of paper cuts.
But probably we can see a lot of the differences in https://bug1638937.bmoattachments.org/attachment.cgi?id=9149930
Testcase by Daniel Holbert in Bug 1638937
Updated•5 years ago
|
Comment 3•4 years ago
|
||
With the patch in Bug 1340715, Firefox now behaves like Chrome for the testcase in comment 0. Tested on Firefox 106.0a1 (2022-09-01).
Description
•