在Rails应用程序中单击“x”时,引导程序警报不会被忽略

时间:2016-10-08 18:00:16

标签: css ruby-on-rails twitter-bootstrap

点击x时,通知不会消失。

我认为没有任何遗漏所需的CSS课程,所以我不确定为什么这不起作用。

点击x之前:

enter image description here

点击x

enter image description here

application.html.erb

<html>
  <body>
    ...
    <% if flash[:notice] %>
        <div class="alert alert-success alert-dismissible fade out in">
          <button type="button" class="close" data-dismiss="alert">
            <span>&times;</span>
          </button>
          <%= flash[:notice] %>
        </div>
    <% elsif flash[:error] %>
        <div class="alert alert-danger alert-dismissible fade out in">
          <button class="close" data-dismiss="alert">&times;</button>
          <% flash[:error].each do |msg| %>
              <li>
                <%= msg %>
              </li>
          <% end %>
        </div>
    <% elsif flash[:alert] %>
        <div class="alert alert-warning alert-dismissible fade out in">
          <button type="button" class="close" data-dismiss="alert">&times;</button>
          <%= flash[:alert] %>
        </div>
    <% end %>
  </body>
</html>

Gemfile.rb

gem 'bootstrap-sass'

application.scss

@import 'bootstrap-sprockets';
@import 'bootstrap';

我还有什么可以推荐的吗?

1 个答案:

答案 0 :(得分:1)

<强>解。

//= require bootstrap-sprockets添加到a​​pplication.js。

除了@import 'bootstrap-sprockets';

中的application.scss之外,我还不知道这是必需的
相关问题