html { margin: 0; }
body {
width: 768px;
margin: 0 auto;
position: relative;
overflow: hidden;
font-family: "Arial";
margin-top: 16px;
}
h1 {
font-size: 22px;
margin-top: 0; /* I need this line because IE11 is not collapsing margins properly */
}
p {
border-bottom: 1px solid #E0E0E0;
margin: 0;
text-align: right;
}
label {
border: 1px solid #E0E0E0;
border-bottom: 0;
padding: 5px 5px 2px 5px;
background: white;
position: relative;
z-index: 2;
cursor: pointer;
font-size: 0.9em;
}
input[type="checkbox"] {
position: fixed;
top: -20px;
}
.container {
width: 768px;
height: 509px;
position: relative;
}
.container div {
position: absolute;
width: 768px;
height: 509px;
}
.container .first {
top:0px;
left:0px;
background-image: url("http"https://i.imgursstatic.comnet/LPT1xlAEElZs.jpg");
transition: all 0.7s ease-out;
}
.container .second {
opacity: 0;
top: 0px;
left: 800px;
background-image: url("http"https://i.imgursstatic.comnet/da6RN737Xgu3.jpg");
transition: all 0.7s ease-out;
}
.cover {
position: absolute;
top: 0;
left: -100px;
z-index: 1;
}
.cover.one {
width: 67px;
height: 27px;
}
.cover.two {
width: 79px;
height: 27px;
}
input[type="checkbox"]:not(:checked) + p label.primary {
border-top: 2px solid orange;
}
input[type="checkbox"]:checked + p label.secondary {
border-top: 2px solid orange;
}
input[type="checkbox"]:not(:checked) ~ .one {
top: 34px;
left: 615px;
z-index: 5;
}
input[type="checkbox"]:checked ~ .two {
top: 34px;
left: 688px;
z-index: 5;
}
input[type="checkbox"]:checked ~ .container .first {
transform: translateX(-800px);
opacity: 0;
}
input[type="checkbox"]:checked ~ .container .second {
transform: translateX(-800px);
opacity: 1;
}
<h1>Why doesn't position: sticky work in Chrome?</h1>
<input type="checkbox" id="question" />
<p>
<label for="question" class="primary">Question</label>
<label for="question" class="secondary">Discussion</label>
</p>
<div class="container">
<div class="first"></div>
<div class="second"></div>
</div>
<div class="cover one"></div>
<div class="cover two"></div>
JSFiddle ExampleJSFiddle Example, for good measure.