Created
August 10, 2016 21:13
-
-
Save valdrinkoshi/4f2083a3e67c37d0d41b394981fca6ac to your computer and use it in GitHub Desktop.
Stacking context causes scroll
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> | |
<title>Stacking context causes scroll</title> | |
<style> | |
.container { | |
border: 1px solid gray; | |
height: 200px; | |
overflow: auto; | |
/* creates a new stacking context */ | |
transform: translateZ(0); | |
} | |
.tall { | |
background-color: orange; | |
height: 900px; | |
} | |
.fixed { | |
position: fixed; | |
padding: 20px; | |
top: 50%; | |
left: 50%; | |
background-color: yellow; | |
z-index: 9999; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="fixed"> | |
I should not scroll! | |
</div> | |
<div class="tall"></div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment