Setting overflow to hidden in parent div cuts off

2019-07-20 09:00发布

问题:

I'm only seeing this issue in Safari.

When a parent div is set to position:fixed; overflow:hidden;, a child div 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{
    background-color: red;
    width: 200px;
    overflow: hidden;
    height: 400px;
    position: fixed;
}

.inner{
    background-color: silver;
    padding: 20px;
    width: 400px;
    height: 200px;
    position: fixed !important;
    top: 50px;
    left: 40px;
}

Is this a bug in Safari? Any ideas? Workarounds?