简体   繁体   English

如何在 Ruby on Rails 中为下拉列表的文本着色

[英]How to color text of dropdown list in Ruby on Rails

= f.collection_select :budget_line_id,
                            @budget_lines, :id, :description,
                            { prompt: true },
                            class: 'form-control input-sm form-control-sm'

I need to change the text color of elements of this dropdown list.我需要更改此下拉列表元素的文本颜色。

If you can't apply a CSS rule for one of your classes you can add an inline style tag to your collection_select helper:如果您无法为其中一个类应用 CSS 规则,则可以将内联样式标记添加到您的collection_select帮助器:

= f.collection_select :budget_line_id,
                            @budget_lines, :id, :description,
                            { prompt: true },
                            class: "form-control input-sm form-control-sm",
                            style: "select { color: #333333; }"

If you have a stylesheet you should be able to add:如果你有一个样式表,你应该能够添加:

.form-control select option {
  color: #333333;
}

It may require some tweaking either way, depending on the HTML that is being rendered, but one of those should get you close.根据正在渲染的 HTML 的不同,它可能需要进行一些调整,但其中一个应该会让你接近。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在下拉列表中更改选择时更改文本颜色 - change text color on change of selection in dropdown list 菜单折叠后如何更改Bootstrap Navbar下拉菜单列表项的背景颜色和文本颜色 - How to Change the Background Color and Text Color of Bootstrap Navbar Dropdown-menu List Items After Menu Collapses 样式下拉式红宝石 - Style dropdown ruby on rails 如何在下拉菜单中的OnMouseHover上更改文本颜色 - How to change text color on OnMouseHover in a Dropdown Menu 如何更改 Materializecss 选择下拉列表中的文本颜色? - How to change the text color in a Materializecss select dropdown? 在每行下拉列表中的选择更改时更改文本颜色 - change text color on change of selection in dropdown list for each row Ruby on rails下拉列表<select>菜单 - 如何设置样式或将类应用于选项? - Ruby on rails dropdown <select> menu - how to style or apply class to the options? Bootstrap 下拉菜单在 Ruby on Rails 中不起作用 - Bootstrap dropdown not working in Ruby on Rails 如何使用Materialise w / Ruby on Rails在输入中更改预定的下划线颜色 - How to change a predeterminate underline color in an Input with Materialize w/Ruby on Rails 如何创建下拉文本的垂直列表? - How could a vertical list of dropdown text be created?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM