Friday, April 15, 2016

Workaround for overflow restriction affecting fixed-positioned elements in iOS?

Leave a Comment

Edit: The main issue is this: overflow: hidden and overflow: auto affect fixed positioned elements in iOS.

So if I have a fixed positioned modal dialog in a component within a scrolling feature of the page, that element is not displayed wherever it exceeds the bounds of its parent. This is really messed up, as it's not how fixed positioning works on any other system. So what's the official response to this?

Original post:

I have a modal dialog that works fine on desktop and Android, but on any browser on my iPad, the modal dialog, including the modal overlay, gets hidden wherever it exceeds the boundaries of its parent container (even though it is fixed positioned). I know that this isn't how overflow: auto is supposed to work, because it works just fine on all other devices. Anyone else experienced this? I'm sure it has something to do with how iOS handles fixed positions.

Anyway, here's some code:

HTML:

<confirm-dialog ng-if="$ctrl.confirmDlgShowing" on-close="$ctrl.closeDlgs()" on-confirm="$ctrl.deleteInstance()" class="ng-scope ng-isolate-scope">     <div class="modal general modal"><div class="modal-window"><div class="modal-inner" ng-transclude="">        <div style="position:relative" class="ng-scope">         <label class="modal-close" ng-click="$ctrl.onClose()"></label>         <div class="page-heading">             <h2>Are you sure?</h2>         </div>             <input class="btn" type="button" value="Yes" ng-click="$ctrl.confirm()">             <input class="btn" type="button" value="No" ng-click="$ctrl.onClose()">         </div>     </div></div></div> </confirm-dialog> 

SASS:

.container {      overflow: auto;  .modal-window {  // overlay    @include transition(opacity 0.25s ease);    @include position(fixed, 0px 0px 0px 0px);    background: rgba(0,0,0, 0.6);    padding-top: 0.6em;    text-align: left;    z-index: 999999999;    margin: 0 !important;    .modal-bg {       @include position(absolute, 0px 0px 0px 0px);       cursor: pointer;    } }    .modal-inner {   @include transition(opacity 0.25s ease);   background: $modal-background;   border-radius: $base-border-radius;   display: table;   margin: 70px auto;   max-height: 80%;   overflow: auto;   padding: $modal-padding / 2;   z-index: 1000000000;   min-width: 400px;    @media(max-width: $medium-screen) {      max-height: 70%;      padding: $modal-padding;   }  } } 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment