Css 如何使用引导单选按钮?
我正在使用Css 如何使用引导单选按钮?,css,twitter-bootstrap,Css,Twitter Bootstrap,我正在使用bootstrap2.3.2,而单选按钮似乎无法工作。我正在使用Bootstrap网站上的代码: <div class="btn-group" data-toggle="buttons-radio"> <button type="button" class="btn btn-primary">Left</button> <button type="button" class="btn btn-primary">Middle<
bootstrap2.3.2
,而单选按钮似乎无法工作。我正在使用Bootstrap网站上的代码:
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn btn-primary">Left</button>
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary">Right</button>
</div>
与bootstrap网站上的相比:
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" class="btn btn-primary">Left</button>
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary active">Right</button>
</div>
左边
中间的
赖特
不确定为什么它在这里工作不同。查看(请参阅用法部分),您需要初始化按钮:
$('.btn-group').button();
选项一是这个和那个&mdash;一定要包括为什么它是伟大的
确保包含正确的类名并在标题中附加样式表是否包含支持该功能所需的javascript文件?@StevenV是的,我包含boostrap.js,它似乎包含所有组件的所有js。我需要在JS中初始化它们吗?因为现在我所拥有的只是上面的东西。是的。您需要使用$('.btn group').button()
启动该功能。请看一下这个问题:您不必初始化按钮组。请参阅下面的zessx答案,尝试从他的示例中删除初始化脚本并重新运行小提琴。您将看到,所需的引导仅包括基于类的句柄。这不是必需的。试着把它从你的小提琴上移开,你会发现它是由css和include处理的。我相信OP可能没有像下面的海报所提到的那样正确地包含一些文件。
$('.btn-group').button();
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
Option one is this and that—be sure to include why it's great
</label>
</div>