Twitter Bootstrap模态是黑暗的?

use*_*559 8 html javascript twitter-bootstrap

除了模态之外,我的所有引导代码都在工作.Modal显示,但整个屏幕都很暗.也就是说,模态似乎是"落后于"灰色.

  <link href="assets/css/bootstrap.css" rel="stylesheet">
  <link href="assets/css/bootstrap-responsive.css" rel="stylesheet"> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script src="assets/js/bootstrap.js"></script>

  <a href="#myModal" data-toggle="modal">Login</a>

  <div id="myModal" class="modal hide fade in" aria-hidden="true">
      <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">X</button>
           <h3 id="myModalLabel">Log in</h3>
       </div>
       <div class="modal-body">
         <p>
            <form class="modal-form" id="loginform" >
              <input type="text" name="username" placeholder="login" id="username">
              <input type="text" name="password" placeholder="password" id="userpassword">
             </form>
          </p>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            <button class="btn btn-success">Login</button>
        </div>
   </div>
Run Code Online (Sandbox Code Playgroud)

小智 5

看起来您需要在</ head>之前将其添加到脚本中

<script type="text/javascript">
 $(function () { 
    $("#myModal").modal({show:false});
});  
</script>
Run Code Online (Sandbox Code Playgroud)


小智 3

我实在不明白这个问题?

\n\n

我刚刚在 jsfiddle 中尝试了您的代码:http://jsfiddle.net/zFHAJ/一切似乎都工作正常?

\n\n
<!DOCTYPE html>\n<html>\n    <head>\n        <link href="http://moi007.dyndns.org/igestis/theme/iabsis_v2//css/bootstrap.css?2.0-4" rel="stylesheet">\n    <link href="http://moi007.dyndns.org/igestis/theme/iabsis_v2//css/bootstrap-responsive.css" rel="stylesheet"> \n    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>\n    <script src="http://moi007.dyndns.org/igestis/theme/iabsis_v2//js/bootstrap.js?2.0-4"></script>\n    </head>\n    <body>\n\n\n  <div id="myModal" class="modal hide fade in" aria-hidden="true">\n      <div class="modal-header">\n          <button type="button" class="close" data-dismiss="modal">X</button>\n           <h3 id="myModalLabel">Log in</h3>\n       </div>\n       <div class="modal-body">\n            <form class="modal-form" id="loginform" >\n              <input type="text" name="username" placeholder="login" id="username">\n              <input type="text" name="password" placeholder="password" id="userpassword">\n             </form>\n        </div>\n        <div class="modal-footer">\n            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>\n            <button class="btn btn-success">Login</button>\n        </div>\n   </div>\n\n       <a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>\n</body>\n</html>\xe2\x80\x8b\n
Run Code Online (Sandbox Code Playgroud)\n\n

也许您还有其他一些与引导程序冲突的自定义 CSS?

\n

  • 这也发生在我身上。原因是模态不是“body”的直接子代,但在层次结构中相当深。 (7认同)