0

我有以下問題。我認爲應用程序/視圖/家庭/ index.html.erb如何在ROR中應用樣式表一個視圖speficied

<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 /資產/樣式表/ 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; 
} 

的問題在於應用於此控制器主頁的ṕropertiescss(例如border-style-solid)應用於其他控制器的視圖,而不僅僅是控制器主頁的視圖,例如app/views/home/index.html.erb。應用程序的所有表格都有border-style-solid,我希望只有app/views/home/index.html.erb的視圖具有邊框樣式:solid

回答

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; 
} 
+0

感謝Vimsha。我對這個問題感到抱歉。我認爲Rails可以理解每個控制器的樣式表之間的區別 – 2014-12-02 22:49:55

相關問題