Answer the question
In order to leave comments, you need to log in
Explain how position: fixed; works. when is transform used?
I can't figure out how position fixed works. According to the documentation, it attaches the layer to the browser window, but if you use transform, then the work changes, and it is already attached to the layer, and not to the browser window (the behavior becomes like position: absolute, but for a number of facts it is still fixed).
I know that when using transform: translateZ(0); the layer goes into a different stacking mode, this is most likely related to this, who can explain this behavior?
Example https://codepen.io/anon/pen/LdWmJw
Code
<style>
.parent {
width: 30%;
background: blue;
height: 2500px;
float: left;
}
.child {
position: fixed;
width: 50px;
height: 50px;
top: 30px;
left: 50px;
background: red;
}
.parent2 {
width: 30%;
background: green;
height: 2500px;
transform: translateZ(0);
float: left;
}
.child2 {
position: fixed;
top: 30px;
right: 50px;
width: 50px;
height: 50px;
background: red;
}
</style>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent2">
<div class="child2"></div>
</div>
Answer the question
In order to leave comments, you need to log in
who can explain this behaviour?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question