In rails, there is normally a view corresponding to an action. So if you want to do some special styles based on different pages, you can render controller name and action name in your layout file like this:
<body class="#{controller_name} #{action_name}">
<!-- Render something -->
</body>
Let's assumpt that your current page controller is ProductsController, and your action is
index, then you can write your style codes like:
.products.index {
/* some styles */
}
本文介绍了一种在Rails应用中为不同页面设置特定样式的技巧。通过在布局文件中使用控制器名称和操作名称,可以轻松实现针对特定页面的定制化样式。
1636

被折叠的 条评论
为什么被折叠?



