Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap image popup

I am using bootstrap and have a button:

 <button type="button" class="btn btn-primary">Popup image</button>

I have an image on the same directory and would like to have it popup in some kind of overlay where the background is grey if that is possible. I am used to javascript, so normally would do something like onclick and call a function that would do it. But in bootstrap I am unsure of how to do this. Thank you

like image 204
user3443195 Avatar asked Mar 20 '14 17:03

user3443195


People also ask

How do I pop an image in Bootstrap?

Images can be fitted in modal popup using Bootstrap by including <img> tag in the “modal-body” div. The “modal-body” div determines the main content of modal popup. By using the <img> tag, an image can be inserted into it.

How do I create a pop up image in HTML?

This will show up a piece of code, if you want to simply show an image, put the id="popup" directly on your <img> tag.

What is modal image?

Modal Image A modal is a dialog box/popup window that is displayed on top of the current page.


1 Answers

You can do something like this..

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Popup image</button>

<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-body">
            <img src="//placehold.it/1000x600" class="img-responsive">
        </div>
    </div>
  </div>
</div>

Demo: http://www.bootply.com/123443

like image 79
Zim Avatar answered Oct 17 '22 23:10

Zim