0

通常<%=flash[:notice] %>在layyt。当我尝试为它添加一些样式时,我遇到了这样的麻烦。例如:

 text-align: center;
 background: #fde073;

如果没有通知重定向,则页面上没有任何内容,如预期的那样。

但是,如果我添加padding或添加height到 CSS,它会显示通知(没有文本,但背景颜色),即使没有通知提供重定向。

我可以用 JS 修复它,但对我来说似乎很难看。还有其他选择吗?

4

1 回答 1

1

我建议在没有通知时跳过通知 div 的呈现。像这样:

<% if flash[:notice] %>
  <div class='notice'><%= flash[:notice] %></div>
<% end %>
于 2013-05-24T20:27:20.350 回答