2013-02-28 92 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