如何在打开模态框时删除背景淡入淡出

时间:2017-08-06 04:06:20

标签: html css twitter-bootstrap bootstrap-modal

如何在打开模态时删除模态背景淡入淡出,我有一个屏幕,当打开模态时它应该在背景上得到滚动但是隐藏在我的情况下。任何人都可以建议帮助。谢谢。< / p>

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;
 }

2 个答案:

答案 0 :(得分:0)

它导致默认为bootstrap-modal,当模态打开时,您的body获取addClass名为modal-open。该课程使您无法滚动它{overflow: hidden}

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

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

希望它可以帮到你:D

答案 1 :(得分:0)

您可以使用解决方案http://jsfiddle.net/0fscmf3L/2625/

&#13;
&#13;
.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;
}
&#13;
<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>
&#13;
&#13;
&#13;

希望这会对你有所帮助。