欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

bootstrap如何讓dropdown menu按鈕式下拉框長(zhǎng)度一致

 更新時(shí)間:2017年04月10日 10:03:18   作者:兩年之約  
bootstrap框架提供了下拉菜單組件(dropdown),即點(diǎn)擊一個(gè)元素或按鈕,觸發(fā)隱藏的列表顯示出來(lái)。下面通過(guò)本文給大家介紹bootstrap如何讓dropdown menu按鈕式下拉框長(zhǎng)度一致,需要的朋友可以參考下

bootstrap框架提供了下拉菜單組件(dropdown),即點(diǎn)擊一個(gè)元素或按鈕,觸發(fā)隱藏的列表顯示出來(lái)。

1、基本代碼和頁(yè)面展示

按鈕和菜單需要包裹在.dropdown 的容器里,而作為被點(diǎn)擊的元素按鈕需要設(shè)置

data-toggle="dropdown"才能有效。對(duì)于菜單部分,設(shè)置 class="dropdown-menu"才能

自動(dòng)隱藏并添加固定樣式。設(shè)置 class="caret"表示箭頭,可上可下。

<div class="dropdown"> 
<button class="btn btn-default" data-toggle="dropdown"> 
下拉菜單 
<span class="caret"></span> 
</button> 
<ul class="dropdown-menu"> 
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁(yè)</a></li> 
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >資訊</a></li> 
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >產(chǎn)品</a></li> 
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >關(guān)于</a></li> 
</ul> 
</div> 

2、使用進(jìn)階和dropdown-menu長(zhǎng)度問(wèn)題

在解決這個(gè)問(wèn)題之前,先記錄bootstrap的按鈕組功能(btn-group),可以將一組按鈕集成在一個(gè)容器里,且相互之前沒(méi)有間隔。直接貼代碼和顯示效果。

<span style="white-space:pre"> </span><div class="btn-group"> 
 <button type="button" class="btn btn-default">上一頁(yè)</button> 
 <button type="button" class="btn btn-default">下一頁(yè)</button> 
 <button type="button" class="btn btn-default">選擇頁(yè)數(shù)</button> 
 <div class="btn-group"> 
  <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">下拉框 
  <i class="caret"></i> 
  </button> 
  <ul class="dropdown-menu" style="min-width:100%;"> 
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁(yè)</a></li> 
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁(yè)</a></li> 
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁(yè)</a></li> 
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁(yè)</a></li> 
  </ul> 
 </div> 
 </div> 

代碼解析與總結(jié):

首先嵌套了<div class="btn-group">容器,用于在按鈕組中使用按鈕式下拉框,

<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span style="font-size:14px; font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">中的dropdown-toggle的作用是讓按鈕式下拉框的也擁有btn-group的圓邊角。</span> 
<i class="caret">
</i>
<span style="font-size:14px; font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">三角圖標(biāo),使用<span>也可以。
</span> 

data-toggle="dropdown"是html5的標(biāo)簽屬性,指以什么事件觸發(fā),常用的如:modal,popover,tooltips。這里指該button按鈕用于下拉按鈕。并且親測(cè)在html4中使用該屬性,雖然IDE會(huì)發(fā)出警告,但是仍然可以實(shí)際運(yùn)行,此特性作用于html5的其他新屬性,如input標(biāo)簽的placeholder。

<ul class="dropdown-menu" style="min-width:100%;"> min-width:100%屬性用于將下拉框長(zhǎng)度與按鈕長(zhǎng)度保持一致,因?yàn)閎ootstrap并沒(méi)有設(shè)置這一點(diǎn)。原始效果如下: 

以上所述是小編給大家介紹的bootstrap如何讓dropdown menu按鈕式下拉框長(zhǎng)度一致,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論