【问题标题】:new.html.erb doesn't see the background color of style sheetnew.html.erb 看不到样式表的背景颜色
【发布时间】:2015-08-31 14:46:48
【问题描述】:

我在assets中制作样式表,它的名字_loginstyle.css来调整log_in页面和sign_up页面的样式

<style>

body{
    background-color: #FFB6C1;
  }
  label{
    margin-left: 1000px;
    width: 100px;
    display: block;
    color: black; 
    font-size: 20px;
  }
  input[type="email"]{
    margin-left: 1000px;
    width: 250px;
  }
  input[type="password"]{
    margin-left: 1000px;
    width: 250px;
  }
  input[type="checkbox"]{
    margin-left: 1000px;
  }
  input[type="submit"]{
    margin-left: 1000px;
  }
</style>

并在 new.html.erb 中渲染它 它显示除背景颜色之外的所有内容 请有任何帮助 我是红宝石的初学者

这是新的.html.erb

<body>

<%= stylesheet_link_tag "loginstyle", media: "all" %>
<h1 style="margin-left: 1000px;" >Log in</h1>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
  <div class="field">
    <%= f.label :email %><br />
    <%= f.email_field :email, autofocus: true %>
  </div>

  <div class="field">
    <%= f.label :password %><br />
    <%= f.password_field :password, autocomplete: "off" %>
  </div>

  <% if devise_mapping.rememberable? -%>
    <div class="field">
      <%= f.check_box :remember_me %>
      <%= f.label :remember_me %>
    </div>
  <% end -%>

  <div class="actions">
    <%= f.submit "Log in" %>
  </div>
<% end %>

<%= render "devise/shared/links" %>

</body>

【问题讨论】:

    标签: html css ruby-on-rails


    【解决方案1】:

    将 !important 添加到“背景颜色:#FFB6C1;”为“背景颜色:#FFB6C1;!important”

    【讨论】:

    • 当我制作 !important 并删除了样式标签时它起作用了,非常感谢
    【解决方案2】:

    将样式表链接标签移到正文之外。

    【讨论】:

    • 还是同样的问题
    • 从css文件中删除样式标签
    • 当我制作 !important 并删除了样式标签时它起作用了,非常感谢
    猜你喜欢
    • 2012-09-14
    • 2015-10-04
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-22
    相关资源
    最近更新 更多