2ueenO
2ueenO

Reputation: 164

Modal bootstrap, image instead of button

I try to use modal from bootstrap, but instead of a button i would like to use an image. But i don't see at all how to do it. And where to insert

data-toggle="modal" data-target="#myModal

http://getbootstrap.com/javascript/#modals

bootstrap modal

<!-- Button trigger modal -->
<button 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" 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">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </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><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

Upvotes: 8

Views: 24073

Answers (2)

Carol Skelly
Carol Skelly

Reputation: 362700

You can place the image inside a link like this...

<a data-toggle="modal" data-target="#myModal">
  <img src="//placehold.it/100x30">
</a>

Demo: http://bootply.com/98748

Upvotes: 14

Nathan
Nathan

Reputation: 3200

You can keep the button HTML and add a background image to the CSS. See the example in this Stackoverflow question.

Upvotes: 0

Related Questions