4
I am facing the problem of displaying image inside the modal bootstrap.
Use this plugin : Magnific-Popup
Follows the code:
HTML:
<!-- Button trigger modal -->
<button type="button" id="mymodal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- 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" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<a class="test-popup-link" href="http://i.imgur.com/YZ7AGyF.jpg">Open popup</a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
JS:
$(document).ready(function() {
$('.test-popup-link').magnificPopup({
type: 'image'
});
});
Final result:
Here is jsfiddle: http://jsfiddle.net/1aeur58f/106/
NOTE: The image should not be behind the modal, always ahead of the modal.
Some brilliant solution ?
Virgilio Novic, gives a help, when opening a small image, the modal does not turn black. See this example : http://jsfiddle.net/1aeur58f/109/
– Matheus Miranda
@Matheusmiranda I added three more
css
, but, what it will do to centralize the modal so that the image stays totally on it, of course the image has to be larger than the modal rssrs– novic
@Matheusmiranda not only use this css that posted have to center so that he stay behind even I just tested
– novic
Virgilio Novic gets this: http://jsfiddle.net/1aeur58f/113/
– Matheus Miranda
I saw @Matheusmiranda.
– novic