Changing the ratchet modal size and slide in position

249 Views Asked by At

How can I change the ratchet modal so it slides down from the top and only takes up 50% of the screen rather than the full height?

the css for the modal is;

.modal {
  position: fixed;
  top: 0;
  z-index: 11;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  background-color: #fff;
  opacity: 0;
  -webkit-transition: -webkit-transform .25s, opacity 1ms .25s;
     -moz-transition:    -moz-transform .25s, opacity 1ms .25s;
          transition:         transform .25s, opacity 1ms .25s;
  -webkit-transform: translate3d(0, 100%, 0);
      -ms-transform: translate3d(0, 100%, 0);
          transform: translate3d(0, 100%, 0);
}
.modal.active {
  height: 100%;
  opacity: 1;
  -webkit-transition: -webkit-transform .25s;
     -moz-transition:    -moz-transform .25s;
          transition:         transform .25s;
  -webkit-transform: translate3d(25%, 0, 0);
      -ms-transform: translate3d(25%, 0, 0);
          transform: translate3d(25%, 0, 0);
}

I've been playing around with different values but can't get it how I want.

1

There are 1 best solutions below

6
On BEST ANSWER

I'm pretty sure this is close, but cannot really test it at the moment.

transform: translate3d(0,-100%,0); should start the modal at the top of the screen, and transform: translate3d(0,50%,0); should move it to the middle when active. and then the obvious heights changes to 50%...

.modal.active {
    height: 50%;
    opacity: 1;
    -webkit-transition: -webkit-transform .25s;
    -moz-transition: -moz-transform .25s;
    transition: transform .25s;
    -webkit-transform: translate3d(0,50%,0);
    -ms-transform: translate3d(0,50%,0);
    transform: translate3d(0,50%,0);
}

.modal {
    position: fixed;
    top: 0;
    z-index: 11;
    width: 100%;
    min-height: 50%;
    overflow: hidden;
    background-color: #fff;
    opacity: 0;
    -webkit-transition: -webkit-transform .25s,opacity 1ms .25s;
    -moz-transition: -moz-transform .25s,opacity 1ms .25s;
    transition: transform .25s,opacity 1ms .25s;
    -webkit-transform: translate3d(0,-100%,0);
    -ms-transform: translate3d(0,-100%,0);
    transform: translate3d(0,-100%,0);
}