Created
June 3, 2013 17:04
-
-
Save nielsdoorn/5699620 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
#blokje { | |
width: 300px; | |
height: 600px; | |
border: 1px solid black; | |
background-color: #353; | |
transition: 1s; | |
} |
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 id="blokje"></div> | |
<form> | |
<label>Breedte in cm: </label><input type="number" name="width" id="width" placeholder="width in cm" value="30"/> <br /> | |
<label>Hoogte in cm: </label><input type="number" name="height" id="height" placeholder="height in cm" value="60"/> <br /> | |
<input type="button" id="calc" value="calculate" /> | |
</form> |
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 button = document.getElementById('calc'); | |
button.onclick = calculate; | |
calculate(); | |
function calculate() { | |
var width = document.getElementById('width').value; | |
var height = document.getElementById('height').value; | |
var block = document.getElementById('blokje'); | |
var proportion = width / height; | |
blockwidth = proportion * 600; | |
console.log(width, height, blockwidth, proportion); | |
block.style.width=blockwidth+"px"; | |
} |
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":"javascript"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment