Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center a Modal in Semantic-UI-React?

I am new to the Semantic-UI-React framework, and recently ran across a problem that I can't seem to fix. I have a Log in & Sign up Modal on my home page. When the LogIn And Sign Up button is triggered, the Modal pops up. However, I cannot get it to appear in the center of the page. It is on the top of the page, and partially cut off. How do I go about doing this? Thank you in advance for your help!

like image 520
SentientCode Avatar asked Mar 20 '18 20:03

SentientCode


Video Answer


2 Answers

The outer <div> containing the modal dialog has display: block; instead of flex which causes the misalignment. To be more specific, the definition display: flex of .dimmed.dimmable > .ui.visible.dimmer is for some reason overridden by display: block !important imposed by .visible.transition.

You might want to add the following to your CSS to fix this:

.dimmed.dimmable > .ui.modals.dimmer.visible {
  display: flex !important;
}

Or, if you are using css modules:

:global(.dimmed.dimmable > .ui.modals.dimmer.visible) {
  display: flex !important;
}
like image 171
ewcz Avatar answered Oct 13 '22 09:10

ewcz


I came across this issue when learning react just months ago and this is how I sorted this issue.In my .css file under App.js folder just add:

.modal {
    height: auto;
    top: auto;
    left: auto;
    bottom: auto;
    right: auto;
}

Hope it helps.Cheers

like image 8
Johana Avatar answered Oct 13 '22 10:10

Johana