【发布时间】:2016-03-26 16:00:48
【问题描述】:
2020 年更新:这是一篇旧帖,因不清楚而被关闭。我想我一直在寻找的是如何将 !important 添加到 HAML 中的 CSS 属性。
我的 Rails 应用程序有问题。我有这个代码:
= simple_form_for @post, html: { class: "newpost"} do |f|
= f.input :title
= f.input :content
= f.submit :submit
它有效,但看起来不错。我试图寻找答案,我发现你可以添加这个代码:
= f.input :content, class: "name_of_class"
女巫什么都不做。我一直在寻找许多人的答案。
谢谢。
PS:我也在使用 HAML 和 Rails 4
当我在 Chrome 中添加 CSS 时,看起来就像我想要的一样:
但如果我尝试在代码中添加 CSS,则没有任何反应。
【问题讨论】:
-
如果看起来不太好,请将其设置为视图助手中的变量。
def classy; html: {class: "newpost"};end然后在视图中你的表单可以是'classy':simple_form_for @post, classy do |f|
标签: css ruby-on-rails haml