Yes, change the child position to absolute
;
.child {
position: absolute;
top: 10%;
right: 10%;
background: blue;
}
You'll notice, in Safari, the element is actually there but you have overflow
set on your parent
div. And since the child element is fixed
, overflow doesn't apply to it and I believe a fixed
element within another fixed
element still brings it out of document flow and positions it against the DOM - but still respects the parent element width.
Remove overflow: auto
from your parent div and you'll see the child div.
Here's some more reading on nested fixed elements:
CSS: position:fixed inside of position: fixed
Edit:
If the child has to be fixed, you might have to consider changing your markup:
.parent {
position: fixed;
width: 100%;
height: 60%;
}
.content {
position: fixed;
width: 70%;
height: 60%;
background: red;
overflow: auto;
}
.child {
position: fixed;
top: 10%;
right: 10%;
background: blue;
}
<div class="parent">
<div class="content">
Hello <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>gfgfg
</div>
<div class="child">Close</div>
</div>