Rails: How come my personalized stylesheet isn't taking priority over the font family?

I have included the Skeleton boilerplate css in my application from this source. It can be found within the directory app/assets/stylesheets.

app/assets/stylesheets
├── application.css
├── custom.scss
├── normalize.css
└── skeleton.css

The default font family used by Skeleton is sans-serif, with Raleway at the top. I am looking to change this font style.

In order to customize the font, my SCSS file includes the following:

@import "skeleton";

body {
  font-family: serif;
}

main {
  @extend .container;
}

However, despite these changes, the font continues to display as sans-serif.

It seems that my custom SCSS file may be loading before the Skeleton file, as without the @import "skeleton", the @extend .container (which is defined in Skeleton) does not take effect.

I have attempted to ensure that my custom stylesheet loads last by including it in the last position in application.css like so:

 *= require_tree .
 *= require_self
 *= require custom

I have also tried different combinations with Skeleton and its associated normalize sheet:

 *= require_tree .
 *= require_self
 *= require normalize
 *= require skeleton
 *= require custom

Despite these efforts, I still find myself needing to import Skeleton in my custom file and having to use !important in order to override the font-family property.

This situation raises the question - Could my custom stylesheet be loading before Skeleton, and how can I ensure that my stylesheet is loaded last?

Answer №1

One clever workaround is to change the name of your style sheet to something like z.css - this way, it will be loaded last when style sheets are alphabetically organized. It may not be the most conventional approach, but it's a handy little trick.

Answer №2

"If you remove the line "require_tree ." in the CSS directory, it will no longer require all CSS files within that directory.

*= require normalize
*= require skeleton
*= require custom
*= require_self

Additionally, if you use @import in custom.scss, there is no need to add it to the assets pipeline manifest as the sass precompiler handles this automatically.

*= require normalize
*= require custom
*= require_self

In my opinion, it's best practice not to mix @imports from scss with manifest declarations in the assets pipeline as it can make it harder to track where specific code is being applied.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a lively JQ plot and saving it within an HTML file from a .aspx page using C# .net

I am currently in the process of developing a web-based application using Bootstrap. My goal is to save a .aspx page as an HTML file within my application. Upon writing the code: using System; using System.Collections.Generic; using System.Linq; using S ...

I recently edited my htaccess file to redirect my webpage, but now I'm facing issues with my CSS, images, and

Here is the htaccess code I am using: RewriteRule ^example1/([A-Za-z-]+)/?$ example2.php?name=$1 [NC] The page is loading, but the CSS and JS are not rendering correctly. Can anyone assist me in resolving this issue? ...

What's the best way to position an ion-label at the top of the stack

I'm having trouble creating an input label similar to the new Google style. However, when the label moves up, it gets cut in the middle as shown here. Despite trying to adjust the margin, padding, and Z-index, none of these solutions have resolved my ...

Steps to customize a CSS file within node_modules

Is there a way to make changes to a CSS file in the "node_modules" dependency without them being overwritten when I run npm install? I want to keep the modifications I've made to the node module files. ...

Tips for lining up segmented pictures in HTML?

Recently, I was presented with a set of sliced images to insert into an HTML document. These images were not sliced by me, but rather provided as individual pieces. To showcase these images in a grid-like manner, I opted to construct a table layout. Each r ...

Ensure the header remains fixed when scrolling in an HTML page with Bootstrap

I created the following code. However, when I scroll down the table, the header disappears from view. I would like the header to always remain at the top, even when scrolling. Despite searching Google multiple times and trying various solutions, I have no ...

Tips for overlaying text onto a MaterialUI icon

https://i.stack.imgur.com/cFr5Y.pngI am currently working on a project that requires me to overlay a number on top of an icon. Specifically, I am utilizing the MaterialUI ModeComment icon and attempting to display text over it. Despite trying the following ...

Using the ternary operator in various CSS rules

Inside a .hover() function, I've written the code below: $(this).css('background-position', circle.includesXY(e.pageX, e.pageY) ? 'bottom' : ''); I'm wondering how to include additional property:value pairs within ...

The footer should never be positioned below the sidebar

Hello, I'm trying to position my footer below my side navigation bar. It's working fine with the header, but I can't seem to figure out how to do it for the footer. Also, another question - how can I ensure that the text on a smaller screen ...

The issue with displaying inline block is that the divs are not appearing side by side on the

Two of my div elements, namely form-panel and data-panel, are currently not aligned on the same line. How can I use display:inline-block to align them in a single line? Please review the code provided below. I have already used display:inline-block on both ...

Tips for creating a mobile-friendly Bootstrap carousel that is both scalable and zoomable while maintaining the default slide functionality

I have a website using Bootstrap 4.x carousel. The layout is user-scalable with the following viewport meta tag: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2, shrink-to-fit=no">. Currently, users can pinch to z ...

I'm trying to position this div within a table so that it lines up with one of the cells. Can you help me figure out

After implementing the code, here is the current output: <table><tr> <td><div id="adt"></div></td> <!-- 336x280 ad code --> <td id="butw"><div id="butto">Follow @Twitter</div></td> ...

Issues arise with tabbed content as default content fails to display and classes are not added upon clicking

I'm currently working on a tabbed module that consists of three tabs. Here's how it operates: When the user clicks on a carousel_element, it reveals carousel_hidden-text within that div and displays it in another div called carousel_quote. I&ap ...

I plan to compile a collection of names in a text field and then have the ability to select and access each name individually with just a click

I am currently working on a project that involves creating an admin site using Firebase. One of the main features of the site is large text fields that display information which can be modified. For instance, the user management page includes text fields ...

Expanding CSS Grid to Occupy Remaining Area

I'm currently utilizing CSS grid to construct a basic 3 column layout. Here's a snippet of my code... .container { display:grid; grid-template-columns:1fr 1fr 1fr; } ...

Verify whether the content within the Div has been modified

I am currently making changes to content within a <div> element. I would like to determine if the data in the <div> has been modified and, if so, save it in a session to persist on refresh. How can I verify if the data has been edited and then ...

Using Sass to Loop through Specific Items

Currently, I am in the process of developing a SASS loop to iterate over a series of images (let's say 50). My goal is to increment the transition delay by 50ms for every nth-of-type image. However, it appears that the current for loop I have implemen ...

Updating the index page with AJAX in Rails 4: Step-by-step guide

It's surprising that I haven't found answers to my specific questions despite searching extensively. I have an Expenses page where I want to display all expenses for a given month in a table. Currently, I achieve this by adding month and year par ...

The center alignment doesn't seem to function properly on mobile or tablet devices

I've designed a basic webpage layout, but I'm facing an issue with responsiveness on mobile and tablet devices. The problem seems to be related to the width: 100% property in my CSS, but I can't seem to pinpoint the exact solution. While tr ...

Creating a Javascript Polling feature in a Ruby on Rails application

I'm completely new to using javascript and I am currently working on implementing polling in a rails application to display a simplified feed of activities from an activity model. I am closely following the Railscast tutorial on polling which can be f ...