Skip to content

Instantly share code, notes, and snippets.

@distums
Created November 11, 2024 11:55
Show Gist options
  • Save distums/ab1d135c711dbd771a1bd101fb87446f to your computer and use it in GitHub Desktop.
Save distums/ab1d135c711dbd771a1bd101fb87446f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>SVG viewBox Attribute</title>
<style type="text/css">
svg {
border: 1px solid #aaa;
}
</style>
</head>
<body>
<!-- Without viewBox -->
<svg width="200" height="200">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<!-- With viewBox -->
<svg width="200" height="200" viewBox="0 0 200 200">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<svg width="200" height="200" viewBox="0 0 100 100">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<svg width="200" height="200" viewBox="0 0 300 300">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<svg width="200" height="200" viewBox="50 0 100 100">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<svg width="200" height="200" viewBox="-50 0 100 100">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<svg width="200" height="200" viewBox="0 50 100 100">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
<svg width="200" height="200" viewBox="0 -50 100 100">
<circle cx="50" cy="50" r="45" stroke="#000" stroke-width="3" fill="none" />
</svg>
</body>
</html>
@distums
Copy link
Author

distums commented Nov 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment