使用CSS在erb中设置Ruby对象的样式 [英] Using CSS to style Ruby objects in erb

查看:153
本文介绍了使用CSS在erb中设置Ruby对象的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google周围搜索,但找不到该问题的答案。如何使用CSS编辑erb中的RUby对象。例如:

I have Googled around but can't find the answer to this question. How do I use CSS to edit RUby objects in erb. For example:

<%= f.label :email, "Enter your email address for updates" %><br />
<%= f.text_field :email %>

在这里,我想使用CSS为文本和表单框设置样式。我该怎么办?

Here, I want to use CSS to style the text and the form box. How can I do that?

推荐答案

您可以使用:class 指定CSS类的选项:

You can use the :class option to specify a CSS class:

<%= f.text_field :email, :class => "login" %>

然后将其放在您的CSS中:

and then put that in your css:

input.login {
  color: red;
}

此外,如果需要,还可以指定内联CSS:

Also, you can specify inline CSS if you want:

<%= f.text_field :email, :style => "color: red;" %>

这篇关于使用CSS在erb中设置Ruby对象的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆