这里所说的按钮只是Bootstrap设计的能使标签或元素呈现按钮样式的属性,所以为 当然在实际开发中使用Bootstrap,我们可能在任何地方使用按钮,但是你也可能会发现并不是所有的按钮都能按照你的想法去呈现,所以,按钮使用的一些注意事项我们要记住。我们看看官网给我们提出的注意事项。 (1)针对组件的注意事项虽然按钮类可以应用到 (2)链接被作为按钮使用时的注意事项如果 (3)跨浏览器展现我们总结的最佳实践是:强烈建议尽可能使用 另外,我们还发现了 Firefox <30 版本的浏览器上出现的一个 bug,其表现是:阻止我们为基于
我个人在使用中,发现了一个很不好的现象,就是使用<button>时候,为标签添加id属性,使用js操作button的时候,你会发现,在Bootstrap某些组件中JS操作不了这个button,但是当你把<button></button>换成<input />的时候,你会发现你的使用js控制了。具体什么原因我也不知道,也没什么时间深究,可能是Bootstrap的js设置了某些东西吧。所以建议大家在使用button时,需要js操作的,就用input或者a标签。
下面来看看预定义样式 ![]() ![]() Code<!-- Standard button --> <button type="button" class="btn btn-default">(默认样式)Default</button> <!-- Provides extra visual weight and identifies the primary action in a set of buttons --> <button type="button" class="btn btn-primary">(首选项)Primary</button> <!-- Indicates a successful or positive action --> <button type="button" class="btn btn-success">(成功)Success</button> <!-- Contextual button for informational alert messages --> <button type="button" class="btn btn-info">(一般信息)Info</button> <!-- Indicates caution should be taken with this action --> <button type="button" class="btn btn-warning">(警告)Warning</button> <!-- Indicates a dangerous or potentially negative action --> <button type="button" class="btn btn-danger">(危险)Danger</button> <!-- Deemphasize a button by making it look like a link while maintaining button behavior --> <button type="button" class="btn btn-link">(链接)Link</button>
当然我们也可以调整button的大小 ![]() ![]() Code<p> <button type="button" class="btn btn-primary btn-lg">(大按钮)Large button</button> <button type="button" class="btn btn-default btn-lg">(大按钮)Large button</button> </p> <p> <button type="button" class="btn btn-primary">(默认尺寸)Default button</button> <button type="button" class="btn btn-default">(默认尺寸)Default button</button> </p> <p> <button type="button" class="btn btn-primary btn-sm">(小按钮)Small button</button> <button type="button" class="btn btn-default btn-sm">(小按钮)Small button</button> </p> <p> <button type="button" class="btn btn-primary btn-xs">(超小尺寸)Extra small button</button> <button type="button" class="btn btn-default btn-xs">(超小尺寸)Extra small button</button> </p>
呈现的效果: 而且还有,通过给按钮添加 ![]() ![]() Code<button type="button" class="btn btn-primary btn-lg btn-block">(块级元素)Block level button</button> <button type="button" class="btn btn-default btn-lg btn-block">(块级元素)Block level button</button>
下面介绍下按钮的激活状态 当按钮处于激活状态时,其表现为被按压下去(底色更深、边框夜色更深、向内投射阴影)。对于
那么我们怎么呈现激活状态呢?由于 ![]() ![]() Code<button type="button" class="btn btn-primary btn-lg active">Primary button</button> <button type="button" class="btn btn-default btn-lg active">Button</button>
有激活状态,当然也会有禁用状态,在Bootstrap中通过为按钮的背景设置 ![]() ![]() Code<button type="button" class="btn btn-lg btn-primary" disabled="disabled">Primary button</button> <button type="button" class="btn btn-default btn-lg" disabled="disabled">Button</button>
提示: 上面提到的禁用状态类只是通过设置
更多有关Bootstrap的使用,请参考官方文档。 |
|
来自: 昵称10504424 > 《工作》