I'm only seeing this issue in Safari (6.1 os x)
When a parent element is set to position:fixed; overflow:hidden
and a child element is set to position:fixed
and part of it overflows the parent, it gets cut off.
Check out this jsfiddle in Chrome and Safari to see what I mean: http://jsfiddle.net/y2dg65y7/3/
<div class="wrapper">
<div class="inner">
Why is cut off in Safari?
</div>
</div>
.wrapper {
position: fixed;
overflow: hidden;
width: 200px;
height: 400px;
background-color: red;
}
.inner {
position: fixed;
top: 50px;
left: 40px;
width: 400px;
height: 200px;
padding: 20px;
background-color: silver;
}
Is this a bug in Safari? Any ideas? Workarounds?
I found a solution that's working for me in Safari 13.0.2 on macOS Catalina 10.15.
The trick was to split position: fixed
and overflow: hidden
across two divs, like so:
<div class="wrapper">
<div class="wrap2">
<div class="inner">
Great success in safari 13.0.2 on MacOS Catalina 10.15
</div>
</div>
</div>
.wrapper{
background-color: red;
padding: 40px;
width: 200px;
height: 400px;
position: fixed;
top: 0;
left: 0;
}
.wrap2{
background-color: yellow;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.inner{
background-color: silver;
padding: 20px;
width: 400px;
height: 200px;
position: fixed !important;
top: 50px;
left: 40px;
}
And a JS fiddle: https://jsfiddle.net/jxmallett/gsyb326v/1/
Edit: Confirmed this works in Safari on iOS 12.3.1 on an iPad.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With