Skip to content

Instantly share code, notes, and snippets.

@aliciaduffy
Last active August 29, 2015 14:06
Show Gist options
  • Save aliciaduffy/41d1c3c4912049532367 to your computer and use it in GitHub Desktop.
Save aliciaduffy/41d1c3c4912049532367 to your computer and use it in GitHub Desktop.
Inline SVG Ratio Fix for Safari and Android webkit
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>SVG Test Safari No Worky</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div class="wrapper">
<object>
<svg viewBox="0 0 150 150" preserveAspectRatio="none" class="icon">
<use xlink:href="/inline-svgicons.svg#icon-go"></use>
</svg>
</object>
</div>
</body>
</html>
.wrapper {
width: 50%; /* Whatever percentage you like */
}
object {
width: 100%;
display: block;
height: auto;
position: relative;
padding-top: 100%;
}
svg {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment