Skip to content

Instantly share code, notes, and snippets.

@lightjs lightjs/index.html
Last active Mar 11, 2018

Embed
What would you like to do?
SVG resize with non-scaling-stroke value for vector-effect attribute avoiding deformation on path stroke (cross browser)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>SVG resize</title>
<style>
div, svg {
width:100%;
height:100%;
}
text {
font-family: 'Helvetica Neue', Verdana;
font-weight: 100;
font-size: 22px;
text-anchor: middle;
}
</style>
</head>
<body>
<div>
<svg>
<path d="M10,20L40,100L39,200z" stroke="black" stroke-width="2px" fill="none"></path>
<text transform="translate(50,240)">normal</text>
<path transform="translate(100,0)scale(4,1)" d="M10,20L40,100L39,200z" stroke="black" stroke-width="2px" fill="none"></path>
<text transform="translate(240,240)scale(4,1)">scaled</text>
<path vector-effect="non-scaling-stroke" transform="translate(300,0)scale(4,1)" d="M10,20L40,100L39,200z" stroke="black" stroke-width="2px" fill="none"></path>
<text transform="translate(450,240)">fixed</text>
</svg>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.