2013-02-28 90 views
2

我正在使用引導程序來設置單選按鈕的樣式。強制單選按鈕顯示內聯

不幸的是顯示:內聯並沒有在表單上單選按鈕。移動顯示器也不行:內嵌到css中。

<div class="row"> 
    <div class="span6 offset3"> 
    <div style="display:inline"> 
     <%= f.label "status_open", "Open" %> 
     <%= f.radio_button :status, 'Open' %> <br /> 
     <%= f.label "status_active", "Active" %> 
     <%= f.radio_button :status, 'Active' %> <br /> 
     <%= f.label "status_closed", "Closed" %> 
     <%= f.radio_button :status, 'Closed' %> <br /> 
     <%= f.label "status_matched", "Matched" %> 
     <%= f.radio_button :status, 'Matched' %> <br /> 
    </div>  
    <%= f.submit "Submit", class: "btn btn-large btn-primary" %> 
    <% end %> 
    </div> 
</div> 

來源:

<div class="row"> 
<div class="span6 offset3"> 
<form accept-charset="UTF-8" action="/books" class="new_book" id="new_book" method="post"><div style="margin:0;padding:0;display:inline"></div> 

    <label for="book_title">Title</label> 
    <input id="book_title" name="book[title]" size="30" type="text" /> 

    <label for="book_isbn">Isbn</label> 
    <input id="book_isbn" name="book[isbn]" size="30" type="text" /> 

    <label for="book_edition">Edition</label> 
    <input id="book_edition" name="book[edition]" size="30" type="text" /> 

    <label for="book_year">Year</label> 
    <input id="book_year" name="book[year]" size="30" type="text" /> 

    <div style="display:inline"> 
    <label for="book_book_category_fiction">Fiction</label> 
    <input id="book_category_fiction" name="book[category]" type="radio" value="Fiction" /> 
    <label for="book_book_category_non_fiction">Non-fiction</label> 
    <input id="book_category_non-fiction" name="book[category]" type="radio" value="Non-fiction" /> 
    </div> 
    <br /> 
    <input class="btn btn-large btn-custom-black" name="commit" type="submit" value="Create Book" /> 
</form> 
</div> 
</div> 

爲什麼按鈕不顯示嵌入式任何想法?任何想法都不勝感激。

回答

4

如果您想表單元素相互內嵌顯示,你要使用form-inline類。

在你的來源,變化:<div style="display:inline">

到:<div class="form-inline">

,應該讓你在正確的方向前進。還有很多額外的更新可以使整個表單更貼近Bootstrap團隊的指南佈局。

這裏是一個更新的例子: http://jsfiddle.net/dusthaines/GTUK9/

順便說一句,它通常是最佳做法的單選按鈕,在左邊和右邊其對應的標籤 - 我的例子反映了這一點小更新,以及。

其他細節@http://twitter.github.com/bootstrap/base-css.html#forms

+0

非常感謝您的意見!你的建議解決了這個問題。 – 2013-02-28 22:32:59

0

display: inline應該應用於物品本身,而不是容器。請鏈接生成的標記(HTML)以獲取更多幫助。

+0

你能解釋一下你的建議多一點,我應該換用自己的DIV每個元件都具有內嵌的風格? – 2013-02-28 16:40:24

+0

不,請添加引用在頁面「」或外部樣式表中創建的元素的CSS。 – hexblot 2013-02-28 16:42:47

+0

我還是沒有關注。你的意思是? 在哪裏? – 2013-02-28 20:31:03

1

乍一看,你可能想刪除這些<br/>標籤的單選按鈕之間......

+0

我懷疑這一點,但沒有運氣的工具。 – 2013-02-28 16:39:40