我正在尝试在DROPDOWN菜单中创建一个LOGIN模式。 模态在某种程度上可以正常工作,但是 -
根据bootstrap文档,如果我点击模态区域外的任何地方,模态应该关闭
这是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>
<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 = "container">
<div class = "row">
<div class=" col-xs-offset-1 col-xs-10 col-sm-offset-1 col-sm-10 col-lg-offset-2 col-lg-8 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, for FREE!!!</a>
</div>
</div>
</div>
</div>
</div>
<!-- End of LOGIN MODAL -->
另外,有人可以解释class = span3
标记中的input
是什么。我还希望单独使用bootstrap使input
字段更宽。
提前致谢:)
答案 0 :(得分:1)
尝试以下方法:
从modal中删除所有网格引导类。默认情况下,模态居中,不需要使用gird类。
<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" role="document">
<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, for FREE!!!</a>
</div>
</div>
</div>
<!-- End of LOGIN MODAL -->