css - 我可以在 Bootstrap 中使用图像作为按钮吗?

标签 css twitter-bootstrap

我正在尝试使用 Bootstrap 中的切换功能,但想用图像替换默认按钮。该图像的文字为“本周”。旁边的按钮将是一个显示“All Time”的图像。关于如何做到这一点有什么想法吗?

您可以在此处查看网页: http://matthewtbrown.com/test/imageasbutton/

<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active thisweek">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Radio 1     (preselected)
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2" autocomplete="off"> Radio 2
</label>

</div>

rightcolumn .btn-group .btn .btn-primary .active .thisweek {
background-image: url(../images/callout.png);
background-color: transparent;
}

最佳答案

您的意思是您希望将图像作为单选按钮,是吗?

希望,这有帮助:

<style>
/*input[type=radio] {
  display: none;
}*/
</style>

<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active thisweek">
<input type="radio" name="options" id="option1" autocomplete="off" checked><img src="https://placehold.it/200x200">
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2" autocomplete="off"><img src="https://placehold.it/150x150">
</label>

取消注释样式以隐藏单选按钮图形:)

关于css - 我可以在 Bootstrap 中使用图像作为按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42588373/

相关文章:

html - 如何让整个输入文本框充满整个div

css - 使用 CSS 和 Bootstrap 3 突出显示当前悬停在 html 表中的行和列

css - Twitter Bootstrap 下拉截止

css - 使用我的外部样式表覆盖 Bootstrap

python - (Python)从带有 'style:hidden' 标签的网站抓取数据?

jquery - 下拉菜单消失和回来只在IE7问题

html - CSS - 文本背景

html - 在 HTML/CSS 中居中一个 ul 元素

javascript - 如何允许一个按钮根据其类别具有两种不同的行为?

html - 我的 Bootstrap div 内的 DIv 不会右对齐(但文本会)