I have a navbar that is fixed on the homepage but considering the other pages aren't nearly as long there is no need for it to be fixed. How can I have the navbar only fixed on the homepage?
You can do this by applying a class to the homepage's body element and then applying the position:fixed
declaration within the context of that class. For example: the homepage body would be .homepage
and then set .homepage .header {position:fixed;}
.
You can have the navbar in a partial which you include in a "homepage" layout. You can then specify a layout for homepage only, defaulting to application.html.erb (or whatever) for your default layout on the rest of the pages.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.