I am using Rails 3.2.1. How do I add external style sheets in my rails application?
I've tried the following answers to no avail:
public/stylesheets
. I do have a public folder, but I have stylesheets folder under /vendor/assets
.We can import additional CSS files inside another CSS declaration. The @import rule is used for this purpose as it links a stylesheet in a document. This is generally used when one stylesheet is dependent upon another.
An external style sheet is a separate CSS file that can be accessed by creating a link within the head section of the webpage. Multiple webpages can use the same link to access the stylesheet. The link to an external style sheet is placed within the head section of the page.
I'm just going to assume you're already using something like this in your layout:
stylesheet_link_tag 'application'
If you want to refer to an external stylesheet then all you need to do is pass in the url.
stylesheet_link_tag 'application', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css'
If you want to include the actual files in your codebase:
app/assets/stylesheets
is where you should place your main css files.
vendor/assets/stylesheets
is where you should place the css files for any plugins that you might have.
It's the same for js files. For example your application.js
would go in app/assets/javascripts
and a jquery plugin like timeago.js
would go in vendor/assets/javascripts
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With