Last active
August 29, 2015 14:06
-
-
Save aliciaduffy/41d1c3c4912049532367 to your computer and use it in GitHub Desktop.
Inline SVG Ratio Fix for Safari and Android webkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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