I have the following SVG document:
<svg preserveAspectRatio="xMinYMin meet" viewBox="0 0 21 484" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="dropShadow">
<feDropShadow dx="4" dy="0" stdDeviation="4"></feDropShadow>
</filter>
</defs>
<g id="Artboard" stroke-width="5" stroke="#FF0000" fill="#000000" stroke-linecap="round">
<path style="filter: url(#dropShadow)" d="M7.5,8.5 L7.5,471.5" id="path-1"></path>
</g>
</svg>
In Firefox, when I open the SVG document, it simply shows a very thin (not 5 wide) vertical line. In Chrome, it doesn't show anything (nor does it in codepen, here: https://codepen.io/jwir3/pen/BJBqEK ).
I'm not quite sure what I'm doing incorrectly here, but it has something to do with the filter, because, if I remove the filter: url(#dropShadow)
from the path
definition, the line shows up as expected.
You can't use objectBoundingBox units if your shape has no height or width.
The default for filterUnits is objectBoundingBox units so you need to change that to userSpaceOnUse i.e.
When processing filters, different browsers process in different
stroke
.Chrome
considers stroke as a value with a zero pixel, so it does not include it in the filter region.Therefore, to make the result look the same in different browsers, it is better to replace
path
withstroke-width ="5"
, a rectangle with a width of 5px withoutstroke
(stroke="none"
)In addition, the default values for the filter area are:
x =" - 10% "" y = "- 10%" `` width = "120%" `` height = "120%"
- large blur sizes are usually truncated .By default,
filterUnits = "objectBoundingBox"
and therefore the values are specified in percentages.To make it easier to calculate the size of the
filter region
action, specify the value offilterUnits = "userSpaceOnUse" and then you can specify all dimensions for the
filter region` in pixels.