uiit uiit - 1 day ago 3
CSS Question

pop-up model hide beside the body when scroll?

I have created a

button
when i click on
button
then
popup
model display but it will hide beside page body and button also hide when i scroll.I want that when popup appear then i can't scroll my page body.I have created model popup using bootstrap.Here is screenshot LINK



.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s
}

/ * Add Animation */
@-webkit-keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}

@keyframes animatetop {
from {top:-300px; opacity:0}
to {top:0; opacity:1}
}

/* The Close Button */
.close {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}

close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}

.modal-header {
padding: 2px 16px;
background-color: #2098d1;
color: white;
}

.modal-body {padding: 2px 16px;}

.modal-footer {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}

<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Order Services</h2>
</div>
<div class="modal-body">
</div>

</div>
<br>
<div class="row">
<div class="col-lg-8 col-md-8">
<textarea name="message" class="form-control" placeholder="Message" style="width: 100%;height:150px;"></textarea>
</div>
</div>
<br>
<button type="submit" class="submit btn btn-success" style="width:100%;background-color: #2098d1;border-color: #2098d1;">
<h2>Order</h2></button>
</form> <!-- End form holder -->
</div>
<!-- <div class="modal-footer">
<h3>Modal Footer</h3>
</div> -->
</div>

</div>

<div class="container-fluid">
<div class="row">
<div class="col-xs-12"> <button type="button" id="myBtn" class="btn btn-success" style="width:200px;font-size:30px; transform: rotate(-90deg);
transform-origin: right, top;
-ms-transform: rotate(-90deg);
-ms-transform-origin:left, top;
-webkit-transform: rotate(-90deg);
-webkit-transform-origin:left,center;
position: fixed; bottom:30%; right: -73px;
color:white;" class="btn btn-success">Order</button>
</div>
</div>
</div>




Answer

If I have understood correctly you want the modal on top of all other elements. You need to find out the highest z-index of that body, then put a bigger z-index than that to your modal. Suppose if your nav menu or bottom-right popup has the z-index value 50, you need to put your modal on 51 at least. Something like this-

.modal {
    /* ... rest of your css ... */
    z-index: 51;
    /* ... rest of your css ... */
}
Comments