2017-08-06 52 views
0

如何在打开模式时去除模式背景褪色,我有一个屏幕,当打开一个模式时,它应该在背景上获得滚动,但在我的情况下隐藏。任何人都可以请建议help.Thanks。如何在打开模式框时去除背景褪色

screen

<div class="modal fade registermodal" id="login-register-model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
     <div class="modal-body paddingbody"> 
      <div class="modal-content"> 
        <div class="modal-body paddingmodal2"> 
         <form id="login-form" name="loginForm" ng-if="showLoginForm" class="nobottommargin" novalidate=""> 
         <div class="text-center social-login-sec"> 
         <a class="col-xs-12 btn btn-primary social-login-btn" id="facebook_login" rel='nofollow' href="/auth/facebook" target="_self" data-ng-click="onClickSocialBtn();">Facebook</a> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 

CSS

.modal-backdrop { 
    z-index: 0; 
} 
+0

*它应该在背景上得到滚动*我不确定你的意思。 – BSMP

+0

嗨BSMP,我附上了屏幕截图,我正在滚动,但无法访问它,因为它褪色。 – Niton

+0

所以你希望页面可以滚动而不是模态,而模态是打开的?我可以问为什么? (另外,演示您的问题的代码将比屏幕截图更有帮助。) – BSMP

回答

0

它通过bootstrap-modal引起默认情况下,当模式打开,你body得到addClass命名modal-open。那类让你不能把它的滚动{overflow: hidden}

所以要解决这个问题,你只需要删除类,试试这个代码

$('#login-register-model').on('show.bs.modal', function (e) { 
    $("body").removeClass("modal-open") 
}) 

希望它可以帮助你:d

0

这里你去解决方案http://jsfiddle.net/0fscmf3L/2625/

.modal-body .form-horizontal .col-sm-2, 
 
.modal-body .form-horizontal .col-sm-10 { 
 
    width: 100% 
 
} 
 

 
.modal-body .form-horizontal .control-label { 
 
    text-align: left; 
 
} 
 
.modal-body .form-horizontal .col-sm-offset-2 { 
 
    margin-left: 15px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 
<!-- Button trigger modal --> 
 
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModalNorm"> 
 
    Launch Normal Form 
 
</button> 
 

 
<!-- Modal --> 
 
<div class="modal" id="myModalNorm" role="dialog" 
 
    aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="false"> 
 
    <div class="modal-dialog"> 
 
     <div class="modal-content"> 
 
      <!-- Modal Header --> 
 
      <div class="modal-header"> 
 
       <button type="button" class="close" 
 
        data-dismiss="modal"> 
 
         <span aria-hidden="true">&times;</span> 
 
         <span class="sr-only">Close</span> 
 
       </button> 
 
       <h4 class="modal-title" id="myModalLabel"> 
 
        Modal title 
 
       </h4> 
 
      </div> 
 
      
 
      <!-- Modal Body --> 
 
      <div class="modal-body"> 
 
       
 
       <form role="form"> 
 
        <div class="form-group"> 
 
        <label for="exampleInputEmail1">Email address</label> 
 
         <input type="email" class="form-control" 
 
         id="exampleInputEmail1" placeholder="Enter email"/> 
 
        </div> 
 
        <div class="form-group"> 
 
        <label for="exampleInputPassword1">Password</label> 
 
         <input type="password" class="form-control" 
 
          id="exampleInputPassword1" placeholder="Password"/> 
 
        </div> 
 
        <div class="checkbox"> 
 
        <label> 
 
         <input type="checkbox"/> Check me out 
 
        </label> 
 
        </div> 
 
        <div class="form-group"> 
 
        <label for="exampleInputEmail1">Email address</label> 
 
         <input type="email" class="form-control" 
 
         id="exampleInputEmail1" placeholder="Enter email"/> 
 
        </div> 
 
        <div class="form-group"> 
 
        <label for="exampleInputPassword1">Password</label> 
 
         <input type="password" class="form-control" 
 
          id="exampleInputPassword1" placeholder="Password"/> 
 
        </div> 
 
        <div class="checkbox"> 
 
        <label> 
 
         <input type="checkbox"/> Check me out 
 
        </label> 
 
        </div> 
 
        <div class="form-group"> 
 
        <label for="exampleInputEmail1">Email address</label> 
 
         <input type="email" class="form-control" 
 
         id="exampleInputEmail1" placeholder="Enter email"/> 
 
        </div> 
 
        <div class="form-group"> 
 
        <label for="exampleInputPassword1">Password</label> 
 
         <input type="password" class="form-control" 
 
          id="exampleInputPassword1" placeholder="Password"/> 
 
        </div> 
 
        <div class="checkbox"> 
 
        <label> 
 
         <input type="checkbox"/> Check me out 
 
        </label> 
 
        </div> 
 
        <button type="submit" class="btn btn-default">Submit</button> 
 
       </form> 
 
       
 
       
 
      </div> 
 
      
 
      <!-- Modal Footer --> 
 
      <div class="modal-footer"> 
 
       <button type="button" class="btn btn-default" 
 
         data-dismiss="modal"> 
 
          Close 
 
       </button> 
 
       <button type="button" class="btn btn-primary"> 
 
        Save changes 
 
       </button> 
 
      </div> 
 
     </div> 
 
    </div> 
 
</div>

希望这会帮助你。