Created
October 29, 2013 13:49
-
-
Save kejun/7215001 to your computer and use it in GitHub Desktop.
Untitled
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,body { height:100%;} | |
body { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
.rect { | |
position: relative; | |
width: 20em; | |
height: 5em; | |
border: 2px solid; | |
} | |
svg { | |
width: 100%; | |
height: 100%; | |
} | |
.controler { | |
position: absolute; | |
bottom: -5em; | |
left: 50%; | |
transform: translate(-50%,0); | |
} |
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
<div class="rect"> | |
<svg> | |
<g stroke="#f20"> | |
<line x1="0" y1="0" x2="100%" y2="100%" stroke-width="1"/> | |
</g> | |
</svg> | |
<div class="controler"> | |
w: <input type="range" id="w-range"> | |
<br>h: <input type="range" id="h-range"> | |
</div> | |
</div> |
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
var div = document.querySelector('div'); | |
var w = parseInt(getComputedStyle(div, null).getPropertyCSSValue('width').cssText, 10); | |
var h = parseInt(getComputedStyle(div, null).getPropertyCSSValue('height').cssText, 10); | |
document.querySelector('#w-range').addEventListener('change', function() { | |
div.style.width = w * (1 + this.value/100) + 'px'; | |
}, false); | |
document.querySelector('#h-range').addEventListener('change', function() { | |
div.style.height = h * (1 + this.value/100) + 'px'; | |
}, false); |
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
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"result"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment