CSS sheet for Show page

I am trying to add CSS to the show page, but am having trouble. I added it to models.css (this worked). But then, I lost all my styling that I had in the index.html page. Then I tried created a new show.css file - and I still lost all my styling on the index page. Any thoughts on separating the index and show page stylings from eachother?

Posted about 4 years ago by Jeremy Molayem
Posted about 4 years ago by Albert Pak

To add onto Alex's suggestion, I would add `class="<%= controller_name %> <%= action_name %>"` to body tag - that way you can taylor CSS specific to a page.

1
Posted about 4 years ago by Alex Yang

What's confusing about the stylesheets in your Rails app is that despite their names, they don't distinguish between the page you're on. All the CSS from all your stylesheets get applied. In your case, it sounds like your CSS in one stylesheets is overriding the CSS in your other stylesheet.

To fix the issue, you need to add a <div id="your-id"> to your view page. With this, you'll be able to apply CSS to this specific page by targeting this ID.

1