滚动时弹出模型隐藏在身体旁边?

时间:2016-12-01 09:23:59

标签: javascript jquery html css twitter-bootstrap

当我点击button然后button模型显示时,我创建了一个popup但它会隐藏在页面正文旁边,当我滚动时按钮也会隐藏。我希望弹出窗口时出现然后我无法滚动我的页面正文。我使用bootstrap创建了模型弹出窗口。这是截图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>

1 个答案:

答案 0 :(得分:0)

如果我理解正确你想要模态在所有其他元素之上。你需要找出那个体的最高z指数,然后把一个比你的模态更大的z指数。假设您的导航菜单或右下角弹出窗口的z-index值为50,则需要至少将模态设置为51。像这样的东西 -

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