在背景淡化bootstrap下的模态

时间:2013-11-08 07:37:57

标签: javascript css twitter-bootstrap

相关链接 1)Bootstrap modal appearing under background

Bootstrap modal with background fading in

Twitter Bootstrap - why is my modal as faded as the background?

错误 http://jsfiddle.net/jononomo/7z8RZ/7/

图像

enter image description here

CSS / JS

     <script src="~/Scripts/bootstrap.min.js"></script>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="~/Scripts/bootstrap.js"></script>

代码

<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal">Signup</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <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><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

这是一个Asp.Net MVC4应用程序

如果删除导航栏css navbar navbar-inverse navbar-fixed-top但模态位置仍位于左侧,则会删除此淡入淡出错误

所有上述相关链接都定义了相同的问题,但它们都没有帮助解决我的问题

2 个答案:

答案 0 :(得分:1)

您的示例中的

navbar navbar-fixed-top需要z-index > 1040

答案 1 :(得分:0)

将您的代码更改为此

<!--===================navBar===================-->
<div class="navbar navbar-fixed-top"> 
<a href="#registration_modal" data-toggle="modal">
    Register
</a>
</div>
<!--===================modal====================-->
<div id="registration_modal" class="modal hide fade">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
            <h3>Register An Account</h3>
    </div>

    <div class="modal-body">
        Registration form goes here.
    </div>

    <div class="modal-footer">
        <button class="btn btn-secondary" data-dismiss="modal">Cancel</button>
        <button class="btn btn-primary">Register</button>
    </div>

</div>

演示:http://jsfiddle.net/7z8RZ/55/