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
Modal bootstrap, image instead of button
提问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">×</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
回答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 问题中的示例。

![Ruby-on-rails 迁移待定;运行“bin/rake db:migrate RAILS_ENV=development”来解决这个问题[无法继续]](/res/img/loading.gif)