css - 更改 rails 的字体样式 "notices"=>

标签 css ruby-on-rails

当用户退出我的网站时,我会收到以下通知。

def destroy
  session[:user_id] = nil
  redirect_to root_url, :notice => "Logged out!"
end

只有轻微的小问题,“已退出!”注意是无字体样式,而不是更符合我的网站的字体样式(即 font-family: sans-serif)。

我该如何改变这个...?

也许:

def destroy
  session[:user_id] = nil
  redirect_to root_url, :notice => <div class="some_class">"Logged out!</div>
end

然后我们可以在 css 中编辑 .some_class 类...

这是 application.html.crb 代码:

<!DOCTYPE html>
<html>
    <head>
        <title>Welcome!</title>

        <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
        <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
        <%= csrf_meta_tags %>

    </head>

    <body>

    <!--<div id="user_nav">
            <% if current_user %>
              Logged in as <%= current_user.email %>.
              <%= link_to "Log Out", log_out_path %>
            <% else %>
              <%= link_to "Sign Up", sign_up_path %> or
              <%= link_to "Log In", log_in_path %>
            <% end %>
        </div>-->

    <% flash.each do |name, msg| %>
    <%= content_tag :div, msg, :id => "flash_#{name}" %>
    <% end %>

    <%= yield %>

    </body>

</html>

最佳答案

在 application.html.crb 中,编辑以下内容:

<div class="flash">
  <% flash.each do |name, msg| %>
    <%= content_tag :div, msg, :id => "flash_#{name}" %>
  <% end %>
</div>

关于css - 更改 rails 的字体样式 "notices"=>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28787463/

相关文章:

html - 如何将 vh 和 vw CSS 用于一页无滚动响应网页?

ruby-on-rails - Mercurial rails 没有可编辑区域 js 错误 'Uncaught TypeError: Cannot read property ' konqueror' of undefined '

ruby-on-rails - 为现有应用程序编写测试用例(Rspec)

jquery - 如何在 jQuery 中显示子菜单?

html - 如何在 CSS 中设置 float div 的高度?

mysql - ruby on Rails Mysql在ubuntu上安装问题

ruby-on-rails - 如何自动找到用户的位置?

ruby-on-rails - 处理用户发送的 "string contains null byte"

html - 为什么特定 div 元素的属性会传播到其他单独的 div 元素?

css - 导入 typekit url 时使用字体显示