Ruby-on-rails 模态引导程序,图像而不是按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20400223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:06:31  来源:igfitidea点击:

Modal bootstrap, image instead of button

ruby-on-railstwitter-bootstrap

提问by 2ueenO

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

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 -->

回答by Zim

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

演示:http: //bootply.com/98748

回答by Nathan

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

您可以保留按钮 HTML 并将背景图像添加到 CSS。请参阅此Stackoverflow 问题中的示例。