2012-08-25 42 views
3

我有以下設置使用最新的Twitter的引導框架:Twitter的自舉輸入字段的最大寬度

http://jsfiddle.net/hfexR/2/

我現在想的是,輸入字段取最大寬度時,旁邊有沒有按鈕至。

我該如何用純css或twitter-bootstrap本身來做到這一點?

喜歡的東西inline-block的應該去,我只是不想在此刻得到它...

+0

你不應該結合'.span4'和'.well'。您是否嘗試過使用「.row-fluid」並跨越井內? – Sherbrow

+0

1.什麼是錯誤的結合跨度和井2.你能給我一個例子 – bodokaiser

回答

1

編輯:自引導V3,類已經進化所以使用COL-XX-X類以獲得結果說明如下(進一步的變化可能是必要的)


Live demo (jsfiddle)

你可以使用一個.row-fluid和使用.spanX,使輸入填補其容器:

<form class="form-search"> 
    <div class="row-fluid"> 
     <input type="text" class="input-medium search-query span12"> 
    </div> 
</form> 
<form class="form-search"> 
    <div class="row-fluid"> 
     <input type="text" class="input-medium search-query span8"> 
     <button type="submit" class="btn span4">Cancel</button> 
    </div> 
</form> 

看來,是需要按鈕/輸入組合有點修復:

/* May not be the best way, not sure if BS has a better solution */ 
/* Fix for combining input and button spans in a row */ 
.row-fluid > input + button[class*="span"] { 
    float: none;   /* Remove the */ 
    display: inline-block; /* floating */ 
    margin-left: 0;  /* Stick it to the left */ 
} 

最後一件事,你不應該結合.spanX.well因爲padding和邊界和其他的東西,在這裏是an example of why (jsfiddle)

+0

跨班級已經在引導3刪除3. – krock

+0

@ krock確實類已經改變,但答案的精神是相同的,請參閱col-xx- X類和夥伴 – Sherbrow

2

您可以使用TE類輸入的塊級就像這個fiddle

<div class="container"> 
    <div class="span4 well"> 
    <form class="form-search"> 
     <input type="text" class="input-block-level search-query"> 
    </form> 
    <form class="form-search"> 
     <input type="text" class="input-medium search-query"> 
     <button type="submit" class="btn">Cancel</button> 
    </form> 
    </div> 
</div> 
+0

是的,輸入塊級別的技巧和適當的響應。 http://stackoverflow.com/questions/11232627/perfect-100-width-of-parent-container-for-a-bootstrap-input – mcNux

相關問題