rails does not support bootstrap variables

How can I utilize the @screen-sm, @screen-md, and @screen-lg variables without encountering errors in Rails when using the bootstrap-sass gem?

Whenever I substitute pixel values for the @screen-sm, @screen-md, and @screen-lg variables, the browser errors disappear. However, if I use these variables as intended, the Rails error indicates that the arguments are invalid.

I am working with bootstrap-sass 3.0.3.

In my application.js file, I have included //=require bootstrap. Although the Github page https://github.com/twbs/bootstrap-sass suggests that this might lead to variables being unavailable in other files, even after removing this line from my js file, I still couldn't access the variables in my application.css.scss file.

application.css.scss

*= require_self
*= require_tree .
*/
@import "bootstrap";

/* Small devices (tablets, 768px and up) */
@media only screen and (min-width: @screen-sm){ 

}

/* Medium devices (desktops, 992px and up) */
@media only screen and (min-width: @screen-md){ 

}

/* Large devices (large desktops, 1200px and up) */
@media only screen and (min-width: @screen-lg){ 

}

Gemfile

... [Gemfile content remains unchanged]

Answer №1

Today I encountered the same issue. It seems that the problem stems from a confusion between syntaxes (Less and Sass).

If you are working with a Less stylesheet, variables are referenced using the @ symbol. On the other hand, if you are using SCSS (as indicated by the file name application.css.scss), variables should be referenced with $.

To resolve this issue, make sure your stylesheet is written as follows:

...

@import "bootstrap";

/* Small devices (tablets, 768px and up) */
@media only screen and (min-width: $screen-sm){ 

}

...

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

Bootstrap maximizes the utilization of the space in an adjacent column

I am currently working on a React project, and one of the pages includes a left sidebar that takes up 3 column spaces in the container. The main content of the page occupies the remaining width, using an additional 8 columns. The sidebar contains only 7- ...

Setting up custom CSS with bokeh serve is a straightforward process that can enhance the

Is it possible to assign custom CSS properties to a class that has been assigned to a widget using the css_classes parameter when serving the app with bokeh serve --show? from bokeh.models import Button button = Button(label="Press Me", css_classes=[&apos ...

Solving the alignment issue in images and radio buttons with a comprehensive example

Over time, this particular query has been raised multiple times in various settings. The general consensus seems to be that utilizing vertical-align: middle is sufficient for styling purposes. However, a recurring issue appears to be the lack of self-con ...

Inability to click on right header links after adding a top drop-down menu

My website is built on Wordpress. I have a header on the right side and a centered drop-down menu plugin for buddypress links, making the top right links unclickable. I attempted to adjust the z-index properties of the center tab but it did not resolve the ...

Adjust both scrollLeft and scrollTop at the same time

Is there a way to adjust both scrollLeft and scrollTop of a div at the same time? It seems to work in Chrome, Safari, and Opera when set sequentially, but Firefox (older than 4) and IE (even in IE9!) experience glitches where the page moves left and then d ...

Tips for moving or aligning a search box when clicked or focused

I need some help with designing a search box similar to the layout on Google's homepage. I want it to be centered, but when clicked on, I would like it to float to the top left corner of the screen. I have been able to modify the size of the search bo ...

Closing menu smoothly with CSS or JavaScript transition

I've set up a sidebar div and a content div to function as two CSS grid columns. The sidebar itself consists of two additional columns, but here's the basic structure: <div class='site-wrap'> <div class='sidebar' ...

HTML links remain enclosed in a box even after the code has been finalized

Hey there, I have written this code and for some reason, every link shared after it is displaying with a black background. I'm new to coding and can't seem to figure out what I'm doing wrong. Any help would be greatly appreciated. a:link, ...

Is there a way to customize the color of the HR element in a Material-UI Select Field?

https://i.stack.imgur.com/DYeX7.png https://i.stack.imgur.com/CN0T6.png Hi there, I am currently working on a website and using a Select Field component from Material-UI. I am faced with the challenge of customizing the style to change the default light ...

Difficult exam question that is challenging me

Struggling with a mock exam assignment here - trying to create a conversion program from wind speed in meters per second to watts per hour. I've set up a chart with different ranges of m/s to watts, but for some reason, it's not working as expect ...

Is there a way to prevent my <div> from scrolling when the mouse hovers over it?

I currently have a div that is set to scroll infinitely using JavaScript: <script language="javascript"> i = 0 var speed = 1 function scroll() { i = i + speed var div = document.getElementById("content") div.scrol ...

Beginner tips for adding padding in CSS

Could anyone clarify a discrepancy in the material provided here: w3schools.com code example According to the code : th,td { padding:5px; } Also, based on their explanation here: http://www.w3schools.com/cssref/pr_padding.asp The explanation states tha ...

Maximizing Bootstrap card size in Angular4: A step-by-step guide

How can I make Bootstrap cards resizable on top of other elements when clicked on an icon to make it full screen and overlay on other cards? detail.component.html <div class="card card-outline-info" > <div class="card-header bg-info"><h5 ...

Is it possible to add a border to both the tbody and td

I currently have a table that is organized with tbody elements to group rows together. In order to create a grid-like structure, I applied borders to each individual td element within the tbody. However, I also desire to show that the tbodies themselves ar ...

Connecting static CSS files to Django

I am fairly new to working with Django and I am having trouble linking CSS to my project. I have included the necessary static settings in my app's configuration, which allows me to access images in the static folder without any issues. However, when ...

What is the best way to eliminate an unknown border within a string builder table?

My code is generating a PDF and I am encountering an issue with a black bordered cell appearing behind the image in this specific line: sb.AppendLine("<tr><td>" + "~/images/Products/" + imageName + "</td><td>~/images/spacer.gif< ...

Exclusive to Safari browser - menu displays incorrectly

Check out my website. It looks perfect in Chrome, Opera, Firefox, and even the notorious IE. But in Safari, the menu is positioned 11px too low. I'm stumped on what could be causing this issue, any suggestions on how to resolve it? ...

Why isn't the z-index functioning properly in Vue.js styling?

I am currently developing a simple component that displays four steps, indicating the current step and allowing users to navigate through them. I want to create a design where these numbers are enclosed within circles that are evenly distributed in a line ...

Position pictures in the same row in a straight line

I am struggling to align a set of images properly. The screenshot below shows the current layout: My goal is to have all four images lined up in a single row, with any additional images starting on a new row. I have attempted various methods, but none ha ...

HTML haphazard design

My goal was to design a page with an intriguing layout, as seen below. Click here for an example of the intended layout The issue I'm facing is determining the best method to achieve this. I am utilizing bootstrap, and here is what I have implement ...