【问题标题】:Modal bootstrap, image instead of button模态引导,图像而不是按钮
【发布时间】:2013-12-05 12:36:12
【问题描述】:

我尝试使用引导程序中的模式,但我想使用图像而不是按钮。但我根本不知道该怎么做。以及在哪里插入

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

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

引导模式

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

【问题讨论】:

  • 你能创建一个带有背景图片的按钮吗?

标签: ruby-on-rails twitter-bootstrap


【解决方案1】:

您可以将图像放在这样的链接中...

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

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

【讨论】:

  • 谢谢!在另一种情况下对我来说就像一种魅力。万一其他人错过了,您还可以将 href="#" 添加到锚标记以获得预期的鼠标悬停效果
【解决方案2】:

您可以保留按钮 HTML 并向 CSS 添加背景图像。请参阅Stackoverflow question 中的示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-02
    • 2013-07-06
    • 2012-06-13
    • 1970-01-01
    • 2020-04-28
    相关资源
    最近更新 更多