-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svg-gradient doesn't work properly in Firefox #2791
Comments
Sorry, I should also mention I'm on 64-bit Windows 10. Here are the browser versions I'm using: Chrome: 47.0.2526.111 m |
Anyone to confirm? |
Confirmed. If an SVG image defines an intrinsic ratio in any way, then Firefox will honor it when the SVG is used as a background image; even when the SVG in question is configured with The only way to override that is to set an explicit (See: https://developer.mozilla.org/en-US/docs/Web/CSS/Scaling_of_SVG_backgrounds) The jsfiddle in question has a (decoded and pretty-printed) SVG source of: <?xml version="1.0" ?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none"
>
<linearGradient id="gradient" gradientUnits="userSpaceOnUse"
x1="0%" y1="0%" x2="100%" y2="0%"
>
<stop offset="0%" stop-color="#f6f7f8"/>
<stop offset="100%" stop-color="#d0d1d5"/>
</linearGradient>
<rect x="0" y="0" width="1" height="1" fill="url(#gradient)" />
</svg> Its viewbox is setting up an intrinsic ratio, which is not what you'd want. It also contains quite a bit of unnecessary noise that can be stripped out to shrink the SVG down in size. Here's what that SVG should be: <svg xmlns="http://www.w3.org/2000/svg">
<linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#f6f7f8"/>
<stop offset="100%" stop-color="#d0d1d5"/>
</linearGradient>
<rect width="100%" height="100%" fill="url(#g)" />
</svg> And the resulting fiddle: https://jsfiddle.net/vb088x4b/ |
@rjgotten Thanks. |
Workaround background-size: 100%; not work. |
Saw this was still open. Should |
Still; that use-case could also be — and probably should be — resolved with a custom post-compile step, like auto-prefixer handling vendor prefixing. |
@rjgotten Oh I'm not suggesting we drop |
Never mind, seems it is! |
Fixes #2791 - svg-gradient() not working in Firefox
Here's the Less I'm using:
Which gets converted into this CSS:
I've put this CSS into a JSFiddle here: https://jsfiddle.net/kaiyoma/5q2mxeuL/
The gradient works correctly in Chrome, IE11, and Edge, but is very broken in Firefox. Is this a Less issue or a Firefox issue?
The text was updated successfully, but these errors were encountered: