Bootstrap CSS布局之按鈕_javascript技巧

來源:互聯網
上載者:User

按鈕是任何系統都不能缺少的組件,設定到按鈕的大小、顏色、狀態等。

//btn源碼.btn { display: inline-block; padding: 6px 12px; margin-bottom: 0; font-size: 14px; font-weight: normal; line-height: 1.42857143; text-align: center; white-space: nowrap; vertical-align: middle; -ms-touch-action: manipulation;  touch-action: manipulation; cursor: pointer; -webkit-user-select: none;  -moz-user-select: none;  -ms-user-select: none;   user-select: none; background-image: none; border: 1px solid transparent; border-radius: 4px;}

按鈕樣式

btn-default、btn-primary、btn-success、btn-info、btn-warning、btn-danger、btn-link

按鈕大小

btn-xs、btn-sm、btn-lg、btn-block

//源碼.btn-lg,.btn-group-lg > .btn { padding: 10px 16px; font-size: 18px; line-height: 1.3333333; border-radius: 6px;}.btn-sm,.btn-group-sm > .btn { padding: 5px 10px; font-size: 12px; line-height: 1.5; border-radius: 3px;}.btn-xs,.btn-group-xs > .btn { padding: 1px 5px; font-size: 12px; line-height: 1.5; border-radius: 3px;}

所有按鈕的寬度都是文本的長短再加上padding值來決定,若我們需要一個充滿父容器的100%寬度的按鈕,則無法實現。所以有btn-block
btn-block不根據文本收縮,也沒有padding和margin值,而是充滿父容器

//源碼.btn-block { display: block; width: 100%;}.btn-block + .btn-block { margin-top: 5px;}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block { width: 100%;}

多標籤支援

btn相關元素的強大之處,不僅能支援button元素,也能支援a元素和input元素

<a class="btn btn-default" href="#">連結</a><button class="btn btn-default" type="submit">按鈕</button><input class="btn btn-default" type="submit" value="輸入框">

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援雲棲社區。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.