So for some reason the following html code only responds to the notice
id and not the flash
or <%=key%>
classes in my CSS. Why is that? Also, I have some styling which should exist depending on whether I'm showing the flash message or not. However, using the notice
id for styling, the CSS always shows up. However, I need the notice
id for my ajax rendering of the flash message. How can I solve this problem?
<div class="container">
<%= render 'layouts/header' %>
<section class="round">
<div id= "notice">
<% flash.each do |key, value| %>
<div class="flash <%= key %>">
<%= value %>
</div>
<% end %>
</div>
<%= yield %>
</section>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
Here's the CSS:
.error, .alert, .notice, .success, #notice, .info {
padding:0.8em;
margin-bottom:1em;
border:2px solid #ddd;
}
#notice {
background:#e6efc2;
color:#264409;
border-color:#c6d880;
}
And here's the relevant html output. Note that it's only the div.
<section class="round">
<div id= "notice"></div>
<!-- yielded content -->
</section>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…