Currently, I am developing a modal within a React application. The modal's width
is set to auto and its position
is set to fixed
. My goal is to center it horizontally in the middle of the screen.
.Modal {
position: fixed;
width: auto;
z-index: 500;
align-content: center;
background-color: rgba(255, 255, 255, 0.889);
border: 1px solid #ccc;
box-shadow: 5px 5px 5px black;
padding: 0px;
font-size: 12px;
box-sizing: border-box;
transition: all 0.3s ease-out;
}
I have experimented with several solutions found on Stack Overflow to achieve the centering of the modal.
The primary issue I am encountering is that the modal appears above other elements due to its z-index
property. When attempting to change the position
to absolute
as recommended in most solutions, the items rendered below it on the z-index
appear shifted down on the screen. This approach does not suit my requirements.