Created
April 16, 2018 06:57
-
-
Save kwikwag/74b991206c5fd197c70a6ec2c02fd238 to your computer and use it in GitHub Desktop.
SVG img tag sizing problem
This file contains hidden or 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
<html> | |
<head> | |
<style type="text/css"> | |
img { position: absolute; } | |
body { background-color: #000; } | |
</style> | |
<script type="text/javscript"> | |
window.addEventListener('load', function() { | |
function budgeRight() { | |
var imgs = document.querySelectorAll('img'); | |
imgs = Array.prototype.slice.apply(imgs); | |
imgs.forEach(function(img) { | |
var left = parseInt(img.style.left); | |
img.style.left = (left + 1).toString() + "px"; | |
}); | |
} | |
var interval = null; | |
var button = document.getElementById('button-click-me'); | |
button.addEventListener('click', function() { | |
if (interval) { | |
clearInterval(interval); | |
interval = null; | |
} | |
else { | |
interval = setInterval(budgeRight, 500); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<img style="zoom: 2.3; left: 41px; top: 25px;" src="rect_white.svg"> | |
<img style="zoom: 2.3; left: 40px; top: 25px;" src="rect_red.svg"> | |
<img style="zoom: 2.3; left: 31px; top: 35px;" width="9.35" height="23.35" src="rect_red.svg"> | |
<img style="zoom: 2.3; left: 32px; top: 35px;" width="9.35" height="23.35" src="rect_white.svg"> | |
<img style="left: 91px; top: 130px;" width="18" height="42" src="rect_red.svg"> | |
<img style="left: 94px; top: 130px;" width="18" height="42" src="rect_white.svg"> | |
<button id="button-click-me">Click me</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment