Saturday, 15 March 2014

ruby on rails - Limiting CSS styles to one page/view using Bootstrap gem -


How can I limit the styles to a page / view using the Bootstrap-Asus gem?

For example, I created an app using GEM, and everything works fine I have created a test scene, and the code added for the bootstrap cover page (). To get the right styles for working I have imported the cover.css file into my property and it application like this. Called in CSS:

  @import "cover";  

However this effect was that it is global and all my thoughts look like this. How do you limit style like index.html.erb?

You are very close.

Depending on your comment, you probably have a ... / app / views / layout / application.html.erb in which line and lt;% = stylesheet_link_tag 'Application', media: 'all'% & gt; . This is good because it covers all your pages for the common style (since the layout gives the visual base template). Alternatively, this row may appear in each of your pages, if they do not have a normal layout, but it is usually less dry.

To limit a style, with a separate cover_set.scss single line @import "cover"; as you suggested in your OP (There are other ways, but this method is sure to pull in .scss . You can basically use cover.scss if you do not want or It is not required partial preparations.)

Then if you want to apply that style to that scene (s), then use the following snippet:

  & lt ;% Content_for: header do -%> & Lt;% = stylesheet_link_tag 'cover_set', Media: 'All'% & gt; & Lt;% end -% & gt;  

If you just want to use the original cover.scss , then simply cover instead of cover_set Code> Use & lt; HEAD & gt; Tags

content_for structure works for JavaScript and whatever you want & lt; HEAD & gt; tag.


No comments:

Post a Comment