Why aren't the media breakpoints in my SASS project being recognized?

For a React project, I initially used CSS but switched to SASS for incorporating a "dark mode" feature.

To organize my files according to the documentation, I also utilize bootstrap.

/* App.scss */

@import "~bootstrap/scss/bootstrap.scss";
@import './styles/_themes';
@import './styles/_fonts';


h1, h2, h3, h4, h5, h6 {
  font-family: $font-family-secondary;
  @include themed() {
    color: t($title-color)
  }
} 

p {
  font-family: $font-family-primary;

  @include themed() {
    color: t($text-color)
  }
}

hr, .nav-tabs {
  @include themed() {
    border-color: t($text-secondary-color)
  }
}

.base {
  height: 100%;
  width: 100%;
  
  @include themed() {
    background-color: t($background-color)
  }
}

.main {
  width: 750px;

  @include themed() {
    background-color: t($background-color)
  }
}

Initially, I suspected a bootstrap issue, but even my own breakpoints are being overlooked in my files.

/* Footer.scss */

@media (max-width: 767px){
    #footer h5 {
        padding-left: 0;
        border-left: transparent;
        padding-bottom: 0px;
        margin-bottom: 10px;
   }
}

I created a simplified example and shared it on codesandbox: https://codesandbox.io/s/immutable-fire-qu9oe

Please test by resizing the screen and observe the media breakpoints not functioning correctly.

Any insights on what could be wrong?

Thanks! - EDIT:

With guidance from robertp's response, I was able to rectify my custom media breakpoints.

How can I address issues with bootstrap ones?

For instance, in my navbar I have a media breakpoint set:

/* Navbar.scss */

@media (max-width: 571px) {
  .collapsing {
    @include themed() {
      position: absolute !important;
      z-index: 3;
      width: 100%;
      top: 75px;
    }
  }

  .collapse.show {
    @include themed() {
      display: block;
      position: absolute;
      z-index: 3;
      width: 100%;
      top: 75px;
    }
  }

  .navbar.open {
    @include themed() {
      transform: translate(0, 0)
    }
  }

  .overlay.open {
    @include themed() {
      height: 100%;
      opacity: 1;
    }
  }

}

Despite efforts, this approach didn't work. How can I correct all bootstrap grid system classes as well?

EDIT 2:

The issue stemmed from import order. Arranging the bootstrap import at the end of the file resolved the problem!

Answer №1

It appears that the issue may be related to the specificity of the theme. The styling for your footer's H5 element is being dictated by the theme, so you will need to override this with your own custom styles.

Check out this screenshot showing how the themed styling is taking precedence over your media query-based styling:

https://i.stack.imgur.com/b6IFD.png

Try implementing the following solution:

@media (max-width: 767px){
  #footer h5 {
    @include themed() {
      padding-left: 0;
      border-left: transparent;
      padding-bottom: 0px;
      margin-bottom: 10px;
    }
  }
}

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

Trouble Arising from Making a POST Request to Spotify's API

I am currently developing a web application that allows users to search the Spotify Library, add songs to playlists, and then save those playlists to their Spotify Accounts. Almost everything is functioning correctly except for the saving of playlists thro ...

Exploring the capabilities of X-grid within Material v5

I have been working on a React app using the latest v5 alpha version of material-ui. The documentation mentions that 'The data grid components support both v5 and v4'. However, when I tried to import X-grid, I encountered this error: ./node_mod ...

Looking to locate or track duplicate values within a multi-dimensional array?

In a multidimensional array, I am looking to detect and count duplicates. If duplicates are found, an alert should be triggered. Arr =[[2,"sk"],[3,"df"],[7,"uz"],[3,"df"],[7,"gh"]] Suggestions: One way to ...

Is it necessary for me to utilize Parallel Routes in Nextjs 13?

Hello everyone, I've recently delved into the world of Next.js version 13 and I have a question that's been boggling my mind. According to the documentation, Next.js is used for displaying one or more pages within the same layout. But can't ...

Encountering 'no overload matches this call' while developing a useReducer using React with Typescript

import { useCallback, useReducer } from "react"; const ARTIST_REDUCER_TYPES = { ADD: "ADD", }; const artistArray = [...Object.values(ARTIST_REDUCER_TYPES)] as const; type ActionReturnedTypes = (typeof artistArray)[number]; type Re ...

What could be causing my React components to not display my CSS styling properly?

If you're developing a React application and integrating CSS for components, ensure that you have included the style-loader and css-loader in your webpack configuration as shown below: module.exports = { mode: 'development', entry: &apo ...

What is the significance of a listener signaling an asynchronous response with a return of true, only to have the communication channel close before the response could be received?

Currently, I am developing a React application that involves the use of various npm modules. One of these modules is a self-built NPM package called modale-react-rm (available at this link). This package serves as a simple modal component that utilizes the ...

Issues with Formik sign-up

Working on a study project involving React, Typescript, Formik, and Firebase presents a challenge as the code is not functioning correctly. While authentication works well with user creation in Firebase, issues exist with redirection, form clearing, and da ...

Does the history.push() function in React get executed asynchronously?

Utilizing the history object that is passed from a component to a reducer in React, I am conditionally routing to other pages while updating the state. I realize this may not be the optimal way to handle navigation, but surprisingly it is still working. ...

React JS does not allow TextField and Select to change

I am relatively new to full stack development and I am currently working on a project to enhance my understanding of frontend development with React JS. While working on this project, I have been using Redux without any issues so far. However, I am facing ...

What steps can be taken to delay information transmission until a secure password is chosen?

I have implemented the PasswordStrengthBar component. How can I ensure that the request is not sent until a strong password is entered? Essentially, I want to prevent the request from being sent if the password is weak. I am using the useForm hook. < ...

What is the best way to transfer an integer from my main application to a separate JavaScript file?

Currently, I am developing a complex code using React Bootstrap and focusing on creating a Dropdown list that fetches data from the backend database. <Dropdown> <Dropdown.Toggle variant="success" id="dropdown-basic"></D ...

Traverse an array containing nested objects using Javascript

I am facing difficulty printing out objects stored in an array. When I console log, this is the result: console.log(product.categories) https://i.stack.imgur.com/YVprQ.png How can I iterate through these nested objects to display them individually like t ...

Exploring ways to turn off IconButton ripple effect in Material UI?

I have an AppBar that includes an IconButton. When I hover over the button, it displays an oval hover effect. I attempted to disable it by using: disableFocusRipple={true} However, this did not work as expected. Can someone provide me with a solution? h ...

Mastering the Art of Extracting HTML Text from JSON Files

I'm facing an issue in my react app where I can't read the HTML tags used in the content of a JSON file. Here's a snippet of the JSON file: [{ "_id": 9, "title":"Text 9", "subheader":"Dummy header 9", "im ...

Using React Hooks: Can you modify the useState hook from a separate .jsx file?

I have a dilemma with two separate components stored in their own files. One of them is meant to be reusable, so I want to keep them separate. However, I need to update a specific hook within the "child" component from the "parent" component. Passing a val ...

Webpack 4 with React Loadable does not split the vendor bundle based on chunking points

At the moment, I am utilizing webpack 4 along with react loadable to generate chunks. Interestingly, the chunks are dependent on the breakpoint. However, the size of the vendor remains constant. Could it be possible that React loadable does not yet support ...

If the desktop website is zoomed in beyond 150%, it will automatically switch to mobile responsive mode

Whenever the desktop website is zoomed above 150%, it automatically switches to mobile responsive mode. Is there a way to disable this feature? You can find the website in question here: Give it a try by zooming to 150 percent and see for yourself. Appr ...

Is it possible to validate a hidden field with the style 'display:none'?

When a user clicks on the "yes" radio button, a file upload field with display:none property will appear. Validation is then triggered for the file upload. However, even if the user selects "no," the validation for file upload still occurs. Here is the co ...

React Router: A must-have

I've been struggling to make this code work properly. Despite the absence of errors, I have experimented with different methods of importing/exporting and even attempted changing the functions to const. import React, { Component } from "react"; impo ...