Peter Peter - 27 days ago 17
HTML Question

Bootstrap Login Modal

I'm having trouble making this code work with a button. All it does is just pop-up and I can't even close it.

<div id="loginModal" class="modal show" tabindex="-1" role="dialog" 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">×</button>
<h1 class="text-center">Login</h1>
</div>
<div class="modal-body">
<form class="form col-md-12 center-block">
<div class="form-group">
<input type="text" class="form-control input-lg" placeholder="Email">
</div>
<div class="form-group">
<input type="password" class="form-control input-lg" placeholder="Password">
</div>
<div class="form-group">
<button class="btn btn-primary btn-lg btn-block">Sign In</button>
<span class="pull-right"><a href="#">Register</a></span><span><a href="#">Need help?</a></span>
</div>
</form>
</div>
<div class="modal-footer">
<div class="col-md-12">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
</div>
</div>
</div>
</div>


The Button is:

<p align="center"><button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#loginModal"> Login</button> <!-- Modal -->




Thanks in advance

Answer

Try removing the show class from your first div:

    <div id="loginModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">

Instead, you could use fade if you want an effect when the modal pops up

    <div id="loginModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
Comments