Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] modal box absolute center

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #199975
    prophoto
    Participant

    I have a modal box that, just like most modal boxes, should be absolutely centered. I have tried a few of the options here https://css-tricks.com/centering-percentage-widthheight-elements/ and from the comments.

    Now to my issue….the modal box is triggered by a search button that could be 500px or 2000px down the page depending on screen size. All options I have found for using percentages to center it are from the top of the page, not from the portion of the page currently being viewed. Any ideas? Thanks!

    .center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    }

    and I have tried

    .center {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    }

    #199980
    prophoto
    Participant

    Just found that solution too, works like a charm. Thanks.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.