Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created July 28, 2016 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/1fbd2680b476a21bd4e60c0ee4573d58 to your computer and use it in GitHub Desktop.
Save nolanlawson/1fbd2680b476a21bd4e60c0ee4573d58 to your computer and use it in GitHub Desktop.
calc() with no units test
<!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