Bootstrap Modal消失但没有看到内容

时间:2016-07-04 19:20:27

标签: jquery html css twitter-bootstrap

我知道此问题之前已被问过,我确实尝试了所有解决方案,例如将href="#myModal"更改为data-toggle="myModal" 并删除.hide课程。在bootstrap.js之前还包括jQuery 但是LOGIN模式仍然无法正常工作。屏幕会褪色,但看不到任何形式/文字。

我正在尝试在DROPDOWN菜单中包含一个LOGIN模式 这是html

<header class = "header container-fluid  navbar navbar-fixed-top navbar-inverse">

  <div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
  <div class="navbar-header">
  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
   </button>
  <a class="navbar-brand" href="#">Brand</a>
  </div>

<!-- Collect the nav links, forms, and other content for toggling -->
  <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">            
   <ul class="nav navbar-nav navbar-right">
     <li><a href="#">Anime</a></li>
     <li><a href="#">Manga</a></li>
     <li><a href="#">Games</a></li>

     <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>
      <ul class="dropdown-menu">
        <li>


       <!--START of LOGIN MODAL-->



          <a data-toggle="modal" data-target="#myModal" >Log-In</a>
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
              <div class="modal-content" >
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">x</button>
                    <h3>Login </h3>
                  </div>
                  <div class="modal-body">
                    <form method="post" action='' name="login_form">
                      <p><input type="text" class="span3" name="eid" id="email" placeholder="Email"></p>
                      <p>
                        <input type="password"class="span3" name="passwd"       placeholder="Password"></p>
                      <p><button type="submit" class="btn btn-primary">Sign  in</button>
                      <a href="#">Forgot Password?</a>
                      </p>
                    </form>
                  </div>
                  <div class="modal-footer">
                    New here?
                    <a href="#" class="btn btn-primary">Register Now</a>
                  </div>
              </div>
            </div>



     <!--END OF LOGIN MODAL-->



        </li>
        <li><a href="#">Sign-Up</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">Watch Paralax</a></li>
      </ul>
    </li>
  </ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</header><!-- end of header-->

提前致谢:)

1 个答案:

答案 0 :(得分:3)

将你的模态div移到外面,你也忘记了modal-dialog div。

<header class="header container-fluid  navbar navbar-fixed-top navbar-inverse">

  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
   </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Anime</a></li>
        <li><a href="#">Manga</a></li>
        <li><a href="#">Games</a></li>

        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>
          <ul class="dropdown-menu">
            <li><a data-toggle="modal" data-target="#myModal">Log-In</a></li>
            <li><a href="#">Sign-Up</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Watch Paralax</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</header>
<!-- end of header-->

<!--START of LOGIN MODAL-->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">x</button>
        <h3>Login </h3>
      </div>
      <div class="modal-body">
        <form method="post" action='' name="login_form">
          <p><input type="text" class="span3" name="eid" id="email" placeholder="Email"></p>
          <p>
            <input type="password" class="span3" name="passwd" placeholder="Password"></p>
          <p><button type="submit" class="btn btn-primary">Sign  in</button>
            <a href="#">Forgot Password?</a>
          </p>
        </form>
      </div>
      <div class="modal-footer">
        New here?
        <a href="#" class="btn btn-primary">Register Now</a>
      </div>
    </div>
  </div>
</div>

<!--END OF LOGIN MODAL-->