Last active
September 16, 2018 17:24
-
-
Save LeaVerou/f1685a573380ef3f9041842a10965e3d to your computer and use it in GitHub Desktop.
Using calc() in <integer>
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
/** | |
* 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 */ | |
} |
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
<div>1</div> | |
<div>2</div> | |
<div>3</div> |
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
// alert('Hello world!'); |
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
{"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