Tips for implementing [class*="col-"] in a SCSS module within Nextjs

Creating a responsive grid system in my nextjs web app using scss module has been challenging.


/* For desktop: */
.col-1 {
  width: 8.33%;
}
.col-2 {
  width: 16.66%;
}
.col-3 {
  width: 25%;
}

@media only screen and (max-width: 768px) {
  /* For mobile phones: */
  [class*="col-"] {
    width: 100%;
  }
}

An issue cropped up stating that the use of [class*="col-"] is not allowed:

error - ./pages/examples/test.module.scss:56:2
Syntax error: Selector "[class*=col-]" is not pure (pure selectors must contain at least one local class or id)

  54 | @media only screen and (max-width: 768px) {
  55 |   /* For mobile phones: */
> 56 |   [class*="col-"] {
     |  ^
  57 |     width: 100%;
  58 |   }

How do we go about resolving this issue?

Answer №1

Check out this solution:

@media only screen and (max-width: 768px) {
    .row :global [class*="col-"] {
        width: 100%;
    }
}

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

Passing data between screens in React Native can sometimes result in a TypeError where a function is not recognized. This error occurs when attempting to access an undefined variable while trying to pass data from one screen to another

I am working on developing a simple app, and one of the components in this app involves managing books. I have only 4 screens that utilize book objects, so I decided to use props to pass data between these screens. However, I encountered an error stating " ...

Modify the size of a div based on the status of a checkbox using only HTML and CSS

Here is a small project that I created using only HTML & CSS. The goal is to modify the properties of the <div class="pro"> when the checkbox is checked. When this happens, all other <div class="pro"> elements should be hidden and the <art ...

React component for Google reCAPTCHA fails to display after updating state

I'm encountering an issue with my Next.js app that uses react-google-recaptcha. The problem arises in a multi-part form where the view changes as the user progresses through the form. If the user navigates to the view containing the ReCAPTCHA and then ...

Navigating with React: Navbar

I'm encountering an issue with component rendering when I click on the navbar. Currently, when I click the Navbar, the component appears inside the navbar instead of below it. Is there a solution to correct this behavior? Here is the code snippet fro ...

Having trouble establishing a connection to the backend server running on Node.js and MongoDB

I'm experiencing issues connecting to the backend even though I'm inputting valid credentials from the front end. The error I'm encountering is: POST 400 (Bad Request). I'm able to generate the token from the backend, however, I'm ...

Animate elements smoothly between components using React Transition Group (replace one component with a fading in component)

I am currently utilizing react-transition-group to incorporate animations within my application. One specific feature I am working on is a Popup that involves transitioning between two different contents. My goal is to smoothly fade out the initial conten ...

Leveraging the powerful combination of Next.js, Redux, and APIMiddleware to render content prior

Currently, I am in the process of migrating an older application to next.js and encountering difficulties with getServerSideProps not properly awaiting my API calls. The issue lies in the utilization of the outdated APIMiddleware commonly used with early r ...

Issue in React: Unable to choose options from a dropdown menu once a value attribute has been assigned to the component's state

One issue I encountered with my React component that renders a dropdown menu is that although it successfully re-renders the value when new props are received, it disables the option to select a different value. This behavior occurs because I have set th ...

What is the solution for fixing the Typescript error in formik onSubmit?

I encountered an error while using the onSubmit prop of Formik: The type '(values: { email: string; password: string; }) => { type: string; payload: { email: string | null; password: string | null; }; }' is not compatible with the type &apos ...

Implementing both function calls and route changes with Navilink in reactjs

When a user clicks on a navigation link in the popup, I want to not only close the popup but also redirect to a new page. The click function is working correctly, but the "to" function for routing to the new page is not functioning as expected. What is the ...

I attempted to implement the hover effect on a custom Tailwind CSS class I created, but unfortunately, it does not appear to be functioning as expected

For example: .btn {bg-blue-500 text-2 text-orange-300} .btn2 {bg-orange-500 text-2 text-blue-300} Attempted Solution: Edit: Apologies for the oversight in not including the code I was working with... it was late at night. < button className="btn ...

Next.js: An absence of response is observed when a high volume of requests is made on a server-side rendering page with

Currently, I am utilizing Next.js along with a custom server (express js) as demonstrated in the GitHub example. For instance, I have a page located at “/post/[id]” that makes use of Next.js dynamic routing. The issue arises when the number of request ...

How can I ensure the text remains centered within a div, even when there are buttons aligned to the left or

I have a CSS class called .text-align-center that I used to center text. .text-align-center { text-align:center; } However, I noticed that when there is a left or right arrow icon within the <div>, the text does not appear perfectly centered. Is ...

What is the best way to showcase a bootstrap range slider and ensure the corresponding value is reflected in the input field?

I have implemented the bootstrap 5 range component, but I am encountering some issues Why is the dot not displaying in the center of the line even though I added the min value of 1? Is there a way to display the value of the range in the input field? How ...

What can I do to prevent my website's font from getting distorted due to the recommended display settings?

I've noticed that newer laptops typically have a display font-size recommendation of 150%, which is causing issues with viewing my webpage correctly. The items appear larger and stretched out on their screens. Is there a way to ensure that users can ...

Exploring Shopify's Graphql capabilities - Retrieving metafields for all products

I am currently in the process of developing a unique storefront using nextJS and shopify APIs. One key feature I am working on is a personalized catalog filtering system that utilizes metafields. My goal is to efficiently retrieve all products' metaf ...

The Bootstrap 4 navigation bar is failing to extend fully across the width when a dropdown menu

Here is the code I am using for the navigation bar. When I click on the dropdown button, this is how it appears on my webpage: Click here <nav class="navbar navbar-expand-lg navbar-dark bg-color mb-3"> <a class="navbar-brand" ...

I'm having trouble getting this button and icon to align properly. How can I fix this misalignment

Take a look at the HTML code snippet I'm currently working on... <div id="projects"> <H1 class="projects">PROJECTS</H1> <div class="box"></div> <div class="box"></div> <div class="box"></ ...

Learn the process of creating unique NFTs using the innovative Crossmint API

Currently, I am in the process of developing an NFT marketplace that will incorporate the Crossmint API. To enhance my website's functionality, I have successfully integrated the crossmintPayButton using the code snippet provided below. import { Cross ...

Intersection observer callback triggered for non-intersecting images

I am facing an issue with lazy loading images of fixed height. These images are contained within a component called <LazyLoad />, which uses an intersection observer. On the main page, I have multiple instances of these <LazyLoad /> components. ...