我试图弄清楚如何为我的 Rails 3 站点的每个页面设置不同的背景图像。我怎样才能做到这一点,而不必为每个页面重复我的 css 文件中的内容?
应用程序.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Site title</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="container">
<div class="content">
<%= yield %>
</div>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
pages.css.scss
.container {
width: 800px;
height: 640px;
position: absolute;
left: 50%;
top: 50%;
margin-top: -320px;
margin-left: -400px;
background-image: url(amber1.jpg);
background-repeat: no-repeat;
background-color: black;
font-family: times new roman, serif;
text-align: center;
}