我有以下问题。我有视图app / view / home / index.html.erb
<h1 id="title">Index</h1>
<table width="300">
<tr>
<td class="title">Table Users</td>
<td><%= link_to 'Users' ,users_path %></td>
</tr>
<tr>
<td class="title">Table Provinces</td>
<td><%= link_to 'Provinces' ,provinces_path %></td>
</tr>
<tr>
<td class="title">Table BreakPoints</td>
<td><%= link_to 'BreakPoints' ,break_points_path %></td>
</tr>
<tr>
<td class="title">Table Bus Companies</td>
<td><%= link_to 'Bus Companies' ,bus_companies_path %></td>
</tr>
<tr>
<td class="title">Table Seat Types</td>
<td><%= link_to 'Seat Types' ,seat_types_path %></td>
</tr>
</table>
我有一个名为app / assets / stylesheets / home.css.sass的控制器主页样式表
// Place all the styles related to the Home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
td{
text-align: left;
}
table{
margin-left: 170px;
border-style: solid;
}
问题是应用于此控制器主页的属性css(例如border-style-solid)应用于视图,其他控制器不仅仅是控制器主页的视图,例如app / views / home / index。 html.erb。应用程序的所有表都有border-style-solid,我希望只有app / views / home / index.html.erb的视图具有border-style:solid
答案 0 :(得分:1)
在主视图中为表分配一个类,并在home.css中定义该类。像
这样的东西应用程序/视图/家/ index.html.erb
<h1 id="title">Index</h1>
<table class="home-table" width="300">
应用程序/资产/样式表/ home.css.sass
// Place all the styles related to the Home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
table.home-table td{
text-align: left;
}
.home-table{
margin-left: 170px;
border-style: solid;
}