gpt4 book ai didi

ruby-on-rails - ruby on rails 和 bootstrap,使 field_with_errors 水平显示

转载 作者:太空宇宙 更新时间:2023-11-03 17:05:25 25 4
gpt4 key购买 nike

custom.css.scss 文件中

.field_with_errors {
@extend .control-group;
@extend .error;

}

和 html.erb

<%= form_for @timecard , url:{action: "savecard"},html:{class: "form-inline"} do |f| %>
<%= f.label :"Date"%>
<%= f.date_select :starttime ,{use_month_numbers: true }, class: "input-small" %>
<%= f.label :"Hours"%>
<%= f.number_field :hours, class: "input-small" %>
<%= f.label :"Project"%>
<% projects = Project.all.map { |project| [project.name, project.charge_number] } %>
<%= f.select :charge_number, options_for_select(projects) ,{},class: "input-small" , style:"width:150px"%>
<%= f.submit "Save", class: "btn" %>
<%= f.submit "Delete", class: "btn" %>
<%= f.submit "Submit", class: "btn btn-danger",confirm:"You can't edit it agin if you've submitted it" %>
<% end %>

在正常状态下,看起来不错

enter image description here但如果出了什么问题,它看起来像这样 enter image description here

及其生成的html代码

<label for="time_card_Hours">Hours</label>
<div class="field_with_errors"><input class="input-small" id="time_card_hours" name="time_card[hours]" type="number" /></div>
<label for="time_card_Project">Project</label>

最佳答案

因为您使用的是内联表单,而 div 显示为 block 默认值。尝试

.field_with_errors {
@extend .control-group;
@extend .error;

display: inline-block;
}

关于ruby-on-rails - ruby on rails 和 bootstrap,使 field_with_errors 水平显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18307376/

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