Skip to content

Instantly share code, notes, and snippets.

@yawnoc
Last active June 6, 2022 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yawnoc/8f75508b298e7def04ecef2731bf983a to your computer and use it in GitHub Desktop.
Save yawnoc/8f75508b298e7def04ecef2731bf983a to your computer and use it in GitHub Desktop.
SVG marker non-scaling-stroke: inline versus external
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Inline vs img test</title>
</head>
<body>
<h2>Inline</h2>
<svg width="100" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 5 5">
<style>
line {
stroke: black;
vector-effect: non-scaling-stroke;
}
polyline {
fill: none;
}
</style>
<defs>
<marker id="plus" viewBox="-1 -1 2 2"
markerUnits="userSpaceOnUse"
refX="0" refY="0" markerWidth="2" markerHeight="2">
<line x1="-1" y1="0" x2="1" y2="0"/>
<line x1="0" y1="-1" x2="0" y2="1"/>
</marker>
</defs>
<polyline points="1,1 4,1"
marker-start="url(#plus)"
marker-mid="url(#plus)"
marker-end="url(#plus)"
/>
<line x1="1" y1="4" x2="4" y2="4"/>
</svg>
<h2><code>&lt;img&gt;</code></h2>
<img alt="" src="external.svg" width="100">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment