2017-03-03 46 views
2

我试图在Bootstrap中使用切换功能,但想用图像替换默认按钮。该图片的文字为“本周”。它旁边的按钮将是一个图像,显示“所有时间”。任何想法如何做到这一点?我可以在Bootstrap中使用图像作为按钮吗?

你可以看到网页都在这了: 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; 
} 

回答

1

你意味着你需要的图片作为一个单选按钮是吗?

希望,这有助于:

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

取消注释风格隐藏单选按钮图形:)

相关问题