gpt4 book ai didi

css - 设置 text_field 宽度,样式有效但类无效

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

我正在尝试改变某些输入字段的大小。我可以让它与内联样式一起工作,但尝试使用 twitter bootstrap 或仅使用一个类是行不通的。

我的表格有

<tr>
<div class="field">
<td><%= f.label :item %></td>
<td><%= f.text_field :item, style: "width: 150px" %></td>
</div>
</tr>


<tr class="field_100">
<div class="field">
<td ><%= f.label :number_of_rolls_fill %></td>
<td><%= f.number_field :number_of_rolls_fill, class: "field_100" %></td>
</div>
</tr>

我看到的是

enter image description here

换句话说,内联样式有效但类无效。

我在 application.css 中设置了一个类

field_100 {
width: 100px !important;
background-color: #2AADD5 !important ;
}

如果我在页面上查看源代码,我会看到

<tr>
<div class="field">
<td><label for="bedsheet_line_item">Item</label></td>
<td><input style="width: 150px" type="text" value="1" name="bedsheet_line[item]" id="bedsheet_line_item" /></td>
</div>
</tr>

<tr class="field_100">
<div class="field">
<td ><label for="bedsheet_line_number_of_rolls_fill">Number of rolls fill</label></td>
<td><input class="field_100" type="number" value="1" name="bedsheet_line[number_of_rolls_fill]" id="bedsheet_line_number_of_rolls_fill" /></td>
</div>
</tr>

如果我检查我尝试使用该类的第二个字段,它指向我的 style.css 主模板的第 1122 行左右。也就是下面的第二 block

  input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="color"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="month"], input[type="number"], input[type="range"], input[type="tel"], input[type="time"], input[type="week"], textarea
{
background: #FFFFFF;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
border:1px solid #B9B59D;
margin:0 auto;
}
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="color"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="month"], input[type="number"], input[type="range"], input[type="tel"], input[type="time"], input[type="week"], textarea
{
width: 100%;
padding: 4px 0;
color: #302E22 !important;
font-size: 13px;
font-family: Arial, 'Arial Unicode MS', Helvetica, Sans-Serif;
font-weight: normal;
font-style: normal;
text-shadow: none;

这些是内部使用率较低的应用程序,因此如有必要,我可以使用内联样式。但是,我想让它与类一起工作。我的计划是有不同的类,例如 field_150、field_200 等。

最佳答案

您忘记了代码中类名前面的点:

field_100 {
width: 100px !important;
background-color: #2AADD5 !important ;
}

您的样式只会应用于 - 标签。

使用点按类名选择:

.field_100 {
width: 100px !important;
background-color: #2AADD5 !important ;
}

关于css - 设置 text_field 宽度,样式有效但类无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41108410/

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