CSS styling of flash message

廉价感情. 提交于 2019-12-05 08:50:26
Nikita Barsukov

Either add a rule for parent div with id notice:

#notice {
  css_formatting_here
}

Or add a rule for child divs:

.flash {
  css_formatting_here
}

The child div of errors container has multiple classes separated by whitespace. flash is one of them. Thus you can add a CSS rule for that class, and it will work.

Look here for more such examples: Hidden features of CSS

Looks like the CSS calls for a class .notice, but the div has an ID instead.

EDIT

The CSS is not responding to the flash or <%= key %> classes, but it is responding to the notice id. Unfortunately, if I style with the notice id, some styling appears that should be dependent on whether there is a flash message or not. How can I fix this

You could add a conditional test around the div:

<% unless flash.empty? %>
  <div id="notice">
    <% flash.each do |key, value| %>
      <div class="flash <%= key %>">
        <%= value %>
      </div>
    <% end %>
  </div>
<% end %>

In your css file type:

.alert-success {
    dosomestyling;
}

.alert-danger {
    dosomestyling;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!