【问题标题】:How to add !important to CSS attributes on HAML elements [closed]如何在 HAML 元素的 CSS 属性中添加 !important [关闭]
【发布时间】: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


【解决方案1】:

尝试从表单中删除类 newpost 并将表单与您的 newpost 类放在一个 div 中。我更喜欢将字段放在 div 中并从 sass 更改输入样式。

【讨论】:

    猜你喜欢
    • 2019-06-28
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    • 2013-06-07
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多