Created
July 28, 2016 18:52
-
-
Save nolanlawson/1fbd2680b476a21bd4e60c0ee4573d58 to your computer and use it in GitHub Desktop.
calc() with no units test
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 lang="en"> | |
<head> | |
<style> | |
#myelement { | |
line-height: 6em; | |
background-color: pink; | |
} | |
#myelement { | |
line-height: calc(6 / 2); | |
} | |
</style> | |
</head> | |
<body> | |
<h1>calc() with no units test</h1> | |
<div id="myelement">hello world</div> | |
<script> | |
(function () { | |
var myelement = document.getElementById('myelement') | |
var style = getComputedStyle(myelement) | |
var span = document.createElement('span') | |
span.innerHTML = 'My line height is: ' + style.lineHeight | |
if (style.lineHeight === '48px') { | |
span.innerHTML += '<br/>Success! Got the correct line height.' | |
} else { | |
span.innerHTML += '<br/>Boo! Got the wrong line height.' | |
} | |
document.body.appendChild(span) | |
})() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment