drublic / css-modal

A modal built with pure CSS, enhanced with JavaScript
https://drublic.github.io/css-modal
MIT License
1.82k stars 211 forks source link

Option / plugin to place modal vertically centered #166

Open drublic opened 10 years ago

drublic commented 10 years ago

This is a suggestion from issue #164.

jgadbois commented 9 years ago

I'd also like to see this

jolidog commented 8 years ago

With transforms2D this can easily be achieved. We make the top and left 50% and then bring it back with transform: translate(-50%, -50%). We don't even care what the width or height of the modal is, it will be perfectly centered.

The issue it raises is the placement of the close button, but that could be solved by having the close button separate from modal background, they could both be links with the same behaviour. The close button would inside the header or wherever users want to place it.