Slip Slip - 5 months ago 15
HTML Question

Centering div in modal window

I'm using flexbox in my modal window. But it doesn't vertically center.

.menu-wrapper {
display: flex;
align-items: center;
justify-content: center;
align-content: center;
}
.menu-window {
display: flex;
background:white;
margin: auto;
}


Example

Answer

When you open modal the display propiety changes to block. Set the display to flex:

function topMenuShow() {
    topMenuWindow.style.display = (topMenuWindow.style.display === "flex") ? "none" : "flex";
}