"Centered Processing Modal"
Bootstrap 3.0.3 Snippet by travislaynewilson

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <h3>Centered Processing Modal <br /><small>Create a simpler, auto-centered modal to tell the user something is processing and block their input!</small></h3> <p><code>NOTE: The 'X' button in the modal is provided for testing purposes only, and can be removed to make the modal uninterruptable.</code></p> <br /> <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#processing-modal"> <i class="glyphicon glyphicon-play"></i> Start Processing </button> </div> </div> <!-- Static Modal --> <div class="modal modal-static fade" id="processing-modal" role="dialog" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body"> <div class="text-center"> <img src="http://www.travislayne.com/images/loading.gif" class="icon" /> <h4>Processing... <button type="button" class="close" style="float: none;" data-dismiss="modal" aria-hidden="true">×</button></h4> </div> </div> </div> </div> </div>
.modal-static { position: fixed; top: 50% !important; left: 50% !important; margin-top: -100px; margin-left: -100px; overflow: visible !important; } .modal-static, .modal-static .modal-dialog, .modal-static .modal-content { width: 200px; height: 200px; } .modal-static .modal-dialog, .modal-static .modal-content { padding: 0 !important; margin: 0 !important; } .modal-static .modal-content .icon { }

Related: See More


Questions / Comments:

This is amazing. ! Thanks. Is there a way to make the greyed-out area fill the entire screen ? Because as it is right now, the user could still press any button or link that is not covered by that area ...

Joverse () - 10 years ago - Reply 0


I would try putting the modal at the end of your body tag (or at least outside of the most parent container). Hope that works out!

Travis Layne () - 10 years ago - Reply 0


Nice :D

Mar Carlo Reyes Tuico () - 10 years ago - Reply 0


Exactly what I was looking for - thank you.
Any idea how I'd trigger this from jQuery/JavaScript?

simonl () - 10 years ago - Reply 0


Well, I've got it appearing using:

$( '#modal-processing' ).modal( { show: true } );

but setting {show:false} doesn't make it disappear - any ideas?

simonl () - 10 years ago - Reply 0


Aha!



$( '#modal-processing' ).modal( 'toggle' );

simonl () - 10 years ago - Reply 0


Actually, 'toggle' was acting a bit funky in my code, but then I discovered $( '#modal-processing' ).modal( 'hide' ); - perfect, if a little obvious! (in hind-sight).

simonl () - 10 years ago - Reply 0


Thanks for your implemantation Travis, but I have a dumb question: How the modal will close when my request is complete?

Tudão () - 10 years ago - Reply 0


LOL thats a fair question. This can be closed with the Modal JavaScript API provided by Bootstrap:

$('#myModal').modal('hide');

Hope that helps!

Travis Layne () - 10 years ago - Reply 0


Travis your snippets are awesome! What would I do without you

Umran Hussein () - 10 years ago - Reply 0


Glad I can help! I'm about to push my float label pattern sample for Bootstrap - be sure to check it out!

Travis Layne () - 10 years ago - Reply 0


Instead using a .GIF, you could've used a font icon and some basic CSS3 to do the rotating cogwheel.

EdgeOfMystery () - 10 years ago - Reply 0


Or use: < i class="fa fa-cog fa-5x fa-spin" > < / i >

Víctor Avendaño Fuentes () - 10 years ago - Reply 0


Good suggestion, but I wanted to favor the most cross-browser- and cross-platform-solution for a demo like this. For a process this important, ensuring that everyone can see it anywhere is the most important aspect.

If you have the luxury of dealing only with CSS3 browsers, that would be a great way to do it.

Travis Layne () - 10 years ago - Reply 0


So simple but so awesome!

Alex () - 10 years ago - Reply 0


Thanks!

Travis Layne () - 10 years ago - Reply 0