gpt4 book ai didi

css - 使用 btn-block 使 Bootstrap-Select 按钮全宽(响应)

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:56 24 4
gpt4 key购买 nike

我正在试验 Bootstrap Select Field from silvio moreto事实证明,它正在使用 Bootstrap btnform-control 类。

我的选择字段被响应列 col-md-1 包围。但是如果内容变得非常大......选择字段宽度超过其周围列的宽度col-md-1,

我发现 btn-block 可以使用父元素的整个宽度,但是如何与 Rails Form Builder 集成呢?

%div.col-md-1
= fields_for :user do |f|
= f.select :interest, options_for_select([
["one",{"data-value" => "one",
"data-content" => "<i class='fa fa-gift'></i> One"}],
["two",{"data-value" => "two",
"data-content" => "<i class='fa fa-question-circle-o'></i> Two"}],
["three",{"data-value" => "three",
"data-content" => "<i class='fa fa-soccer-ball-o'></i> Three"}]
]), {}, :multiple => "multiple",
:title => "Choose what you like",
:class => "btn-block selectpicker"

结果

<select multiple="multiple" title="Choose what you like" 
class="btn-block selectpicker"
name="user[interest][]"
id="user_interest"
style="display: none;">

<div class="btn-group bootstrap-select show-tick btn-block">
<button type="button"
class="btn dropdown-toggle form-control selectpicker btn-default"
data-toggle="dropdown" data-id="searchprofile_interest"
title="One, Two, Three">
<span class="filter-option pull-left">
<i class="fa fa-gift"></i> One,
<i class="fa fa-question-circle-o"></i> Two,
<i class="fa fa-soccer-ball-o"></i> Three</span>&nbsp;
<span class="caret"></span>
</button>
</div>

</select>

有什么办法可以把btn-block 带进按钮吗?

<button type="button" 
class="btn dropdown-toggle form-control selectpicker btn-default"

最佳答案

您必须将 btn-block 附加到 data-style,如图所示 here .所以,你的代码会是这样的:

%div.col-md-1
= fields_for :user do |f|
= f.select :interest, options_for_select([
["one",{"data-value" => "one",
"data-content" => "<i class='fa fa-gift'></i> One"}],
["two",{"data-value" => "two",
"data-content" => "<i class='fa fa-question-circle-o'></i> Two"}],
["three",{"data-value" => "three",
"data-content" => "<i class='fa fa-soccer-ball-o'></i> Three"}]
]), {}, :multiple => "multiple",
:title => "Choose what you like",
:class => "selectpicker"
:"data-style" => "btn-block"

关于css - 使用 btn-block 使 Bootstrap-Select 按钮全宽(响应),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41489992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com