先简单看下对于这个控件官方的说明
Input groupEasily extend form controls by adding text, buttons, or button groups on either side of textual s.Contents Basic example Sizing Checkboxes and radio addons Button addons Buttons with dropdowns Segmented buttons Accessibility
意思就是针对我们平常使用的表单提交功能,可以添加按钮,文本到输入栏的两边的位置。
下面的Contents的七个内容就是它能实现的几个基本功能,这里我们关注第四个button addons就可以了,其它的如果有兴趣可以自行学习。
Button addonsButtons in input groups are a bit different and require one extra level of nesting. Instead of .input-group-addon, you’ll need to use .input-group-btn to wrap the buttons. This is required due to default browser styles that cannot be overridden.
上面一段话就是指,在input groups里面的button和普通的不一样,它需要一个不一样的嵌套层次。其实简单来说,就是我们不再使用input-group-addon,而使用input-group-btn来管理按钮,我给出的demo代码如下所示: