[英]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.