Bootstrap中任何带有 class .btn 的元素都会继承圆角灰色按钮的默认外观,再结合一些选项,可以定义各种按钮样式。
0x01 按钮样式
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>按钮</title> </head> <body> <div> <div> <h1>基本按钮</h1> </div> <p> <a href="#">Default</a> <button type="button">Primary</button> <button type="button">Success</button> <a href="#">Info</a> <a href="#">Warning</a> <button type="button">Danger</button> <button type="button">Link</button> </p> </div> </body> </html>
效果如下:
0x02 调节按钮大小
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>调节按钮大小</title> </head> <body> <div> <div> <h1>调节按钮的大小</h1> </div> <h3>大号按钮</h3> <p> <a href="#">Default</a> <button type="button">Primary</button> <button type="button">Success</button> <a href="#">Info</a> <a href="#">Warning</a> <button type="button">Danger</button> <button type="button">Link</button> </p> <h3>默认大小</h3> <p> <a href="#">Default</a> <button type="button">Primary</button> <button type="button">Success</button> <a href="#">Info</a> <a href="#">Warning</a> <button type="button">Danger</button> <button type="button">Link</button> </p> <h3>小号按钮</h3> <p> <a href="#">Default</a> <button type="button">Primary</button> <button type="button">Success</button> <a href="#">Info</a> <a href="#">Warning</a> <button type="button">Danger</button> <button type="button">Link</button> </p> <h3>微型按钮</h3> <p> <a href="#">Default</a> <button type="button">Primary</button> <button type="button">Success</button> <a href="#">Info</a> <a href="#">Warning</a> <button type="button">Danger</button> <button type="button">Link</button> </p> </div> </body> </html>
效果如下:
0x03 其他按钮
移动端一个按钮占用一行按钮,可以利用.btn-block类来实现块状按钮。Bootsrap通过将announce背景色设置为50%褪色的方式来呈现无法点击的效果:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>其他按钮</title> </head> <body> <div> <div> <h1>其他按钮</h1> </div> <div> <p> <button type="button">Block</button> </p> <p> <button type="button" disabled="disabled">不可用按钮1</button> <a href="#">不可用按钮2</a> </p> </div> </div> </body> </html>
效果如下:
如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题: