Skip to content

Instantly share code, notes, and snippets.

@LeaVerou
Last active September 16, 2018 17:24
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 LeaVerou/f1685a573380ef3f9041842a10965e3d to your computer and use it in GitHub Desktop.
Save LeaVerou/f1685a573380ef3f9041842a10965e3d to your computer and use it in GitHub Desktop.
Using calc() in <integer>
/**
* Using calc() in <integer>
* If yellow underneath green and blue: No calc() support
* If yellow above green and below blue: Multiplication OK, division dropped
* If yellow on top of both green and blue: calc() fully supported
*/
div {
background: yellowgreen;
border: 1px solid;
position: absolute;
z-index: 1;
width: 200px; height: 200px;
}
div:nth-child(2) {
left: 40px; top: 40px;
z-index: 2;
}
div:nth-child(3) {
left: 80px; top: 80px;
background: #4ac;
z-index: 3;
}
div:first-child {
background: yellow;
z-index: calc(1 * 3); /* Works in Chrome, Safari, Firefox, Edge */
z-index: calc(8 / 2); /* Doesn't work */
}
<div>1</div>
<div>2</div>
<div>3</div>
// alert('Hello world!');
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment