Trouble arises in next.js containers when their content exceeds the specified limits due to @media rules adaptation

I've been working tirelessly for the past 2 days to resolve an issue with my next.js project. This is my first time using this technology and I feel like I might be overlooking something crucial.

The problem revolves around three layers (as seen in the 3D View image below) that refuse to shrink below a certain width of 1040px. While the content within these layers resizes properly, there is a significant overflow resulting in a horizontal scroll bar. View screenshot illustrating the issue

I attempted to use @media rules on these layers but they seem ineffective. When I tried making these divs/layers display as {flex}, it caused major glitches across the rest of the website.

I will provide the code for index.js; the header and content are not problematic.

index.js

const Home = () => {
  return (
   <>  
   <main className={containerStyles.container}>
   <Head>
    <title>Title</title>
    <link rel="icon" href="/favicon.ico" />
  </Head>
  <div className={containerStyles.column}>
    <div className={styles.main}>
      <ul>
      <div className={styles.wrapListItem}><Link href="../buy"><li className={styles.listItem}>   <p>Buy </p>       </li></Link></div>
      <div className={styles.wrapListItem}><Link href="../doc"><li className={styles.listItem}>   <p>Documentation</p>        </li></Link></div>
      <div className={styles.wrapListItem}><Link href="../tos"><li className={styles.listItem}>   <p>TOS</p>                  </li></Link></div>
      <div className={styles.wrapListItem}><Link href="../cart"><li className={styles.listItem}>  <p>Cart</p>                 </li></Link></div>  
      </ul>
    </div>
  </div>
  </main>
  </>
  )
  }

export default Home;

global.css

    @import 'Fontfaces.css';
        html,
        body {
          cursor: url("../public/2x/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="680b1d1a1b071a28d4faf6e8fcfbfab5eef3efbcfbeefe79fafaf7ff16eceae2">[email protected]</a>"), auto;
          background-color: black;
          padding: 0;
          margin: 0;
          font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
            Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
          min-width: 1040px;
          z-index: 0;
          
        }
        a {
          color: inherit;
          text-decoration: none;
        }
        * {
          box-sizing: border-box;
        }
        :root{
          --brand-yellow: rgb(255, 217, 0);
        }
        a:active{
          color: var(--brand-yellow);
        }
        .glowing{
          color: #ffef2a;
          font-size: 20px;
          -webkit-animation: glow 3s ease-in-out infinite alternate;
          -moz-animation: glow 3s ease-in-out infinite alternate;
          animation: glow 3s ease-in-out infinite alternate;
        }
        @media(max-width:1040px){
          body{
            max-width: @media(max-width:1040px){
      body{
        max-width: 100vw;
      }
    };
      }
    }

ContainerStyles.module.css

    .container{
    min-height: 80vh;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    background-color: black;
}
.column{
    width: 50%;
    display: flex;
    flex-direction: column;
}
@media(max-width:1040px){
    .container{
        transition: 1s;
        flex-direction: column;
        max-width: 100vw;
        margin-right: 0px;
        
    }
    .column{
        transition: 1s;
        background-color: red;
        width: auto;
        max-width: 100vw;
        margin-right: 0px;
    }
}

Apologies for the messy formatting, it's my first time posting on StackOverflow.

Here is another screenshot showing the layout in a browser.Screenshot

Thank you in advance for any assistance! PS: The exaggerated transitions and colors are solely for debugging purposes, please don't judge xoxo

Answer №1

After seeking advice from a more knowledgeable friend, I learned that incorporating overflow-x: hidden into my @media rules for the body is a common practice and proved to be the solution I needed!

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

The CORS problem arises only in production when using NextJS/ReactJS with Vercel, where the request is being blocked due to the absence of the 'Access-Control-Allow-Origin' header

I've encountered a CORS error while trying to call an API endpoint from a function. Strangely, the error only occurs in production on Vercel; everything works fine on localhost. The CORS error message: Access to fetch at 'https://myurl.com/api/p ...

The div smoothly descended from the top of the page to the center under the control of jQuery

I am trying to implement a feature where a div slides down from the top of the page to the center when a button is clicked. However, my current code seems to be causing the div to slide from the bottom instead of the top. Ideally, I want the div to slide ...

The overflow property is not functioning as anticipated

I've browsed Google and this site, but I couldn't find a solution to my issue. On my webpage, I have a shoutbox and a teamspeak viewer with a specific height for the outer div. The scrollbars don't look good on our new design, so I attempt ...

Currently, I am compiling a list of tasks that need to be completed, but I am encountering a dilemma that is proving difficult to resolve

Recently delved into the world of Javascript and encountered a roadblock that I can't seem to overcome. Here's the snippet of code causing me trouble: add = document.getElementById("add"); add.addEventListener("click", () => { console.log("Ple ...

Explore and find your way to subpages easily with these tips!

As per my understanding, NEXT should automatically generate routes based on my folder structure. I am currently iterating through article posts on the news/index.tsx page, but the URLs are rendering as localhost3000/article-one instead of localhost3000/ne ...

Creating a Cancel Button in JSP/HTML/JS/CSS Form: A Step-by-Step Guide

It is necessary to incorporate the functionality of "save" and "cancel" in the JSP code for this particular form. By selecting "save", the data entered into the form will be submitted to its intended destination. Alternatively, choosing "cancel" will dismi ...

Let's discuss how to include the scrollTop option

I am new to coding and I need help adding a scrollTop margin of +100px to my code. The page already has some top margin but I can't seem to locate it. I'm also having trouble finding where the margin-top is being set in the JavaScript file. /*** ...

The CSS_MODULES encountered a module build error when utilizing the extract-text-webpack-plugin

While processing CSS with CSS modules in a production environment, I encounter an error, but everything works fine in the development environment. Here is the configuration for webpack.base.js: const path = require("path") const webpack = require("webpac ...

Problem with aligning divs in Bootstrap

I am currently facing a challenge when it comes to aligning my div in Bootstrap 3. My goal is to achieve the following: I have experimented with pull and push commands, but it seems like I still need more practice. Code: <div class="container"> ...

Website created using React without the use of Javascript

Currently, I am considering migrating one of my websites that is built using Python-Flask and Jinja2. The reason behind this decision is primarily due to the limitations of Jinja2's developer experience and the fact that Python is not typed by default ...

Elevate with Ease: Tailwind's Height Transition

I've been attempting to implement a transition effect using TailwindCSS, but I haven't found an updated version with the latest features. Here's the code snippet: <div id="fadeInElement" className={visible ? " w-2/3 px-5 t ...

Spinning an SVG circle using a group element

I'm interested in rotating an SVG circle without affecting the rotation of other elements. My attempt to rotate the white circle using rotateZ(15deg) resulted in this: This is the progress I've made so far: https://jsfiddle.net/41hrnojs/ <sv ...

Trouble with Applying Tailwind CSS Styles in React Application Following Scraping of Next.js Page

In my Next.js application (version 13), I have various components styled with Tailwind CSS. These components are pulled from a React CMS system using Node.js and sanitized with the cheerio library. After scraping, the resulting HTML content is sent to the ...

Struggling with getting render props to work in Next.js version 13

Looking to develop a custom component for Contentful's next 13 live preview feature in the app directory, I thought of creating a client component that can accept a data prop and ensure type safety by allowing a generic type to be passed down. Here is ...

Error with Hydration Caused by Conditional Rendering in Client-Side Component

Having issues with conditional rendering in my client components. Every time I do conditional rendering based on a cookie value, I keep getting this error: react-dom.development.js:7076 Uncaught Error: Hydration failed because the initial UI does not match ...

Nextjs throwing an error: createSVGPoint is not a valid function

I'm currently developing a simple game engine using Nextjs, React hooks, and SVG elements. One of the challenges I'm facing is detecting collisions between two SVG elements within the game. Initially, I tried using the syntax: circle.isPointInF ...

Dynamic grid arrangement showcasing cells of varying heights

I am dealing with a grid layout where cells are dynamically generated using the following code: <style> .calWrapper{ width:200px; float:left; } </style> <div class="container"> <?php for($i=1; $i<=12; $i++){ echo ...

How can I align a sub-submenu horizontally using CSS?

I've built a nested menu using the ul/li tags, and I'm looking to align the second and third sub-menus horizontally with the first submenu. Here is my current visual layout: , and this is what I want it to look like: CSS/HTML: body { back ...

How can I use Vue.js @scroll to create a dynamic CSS property?

I am developing a vuejs component for my project and I am looking to implement a zoom functionality on scroll within a div, similar to Google Maps. <div @scroll="zoomOnScroll"> <Plotly :data="info" :layout="layout" :display-mode-bar="false"&g ...

Mobile devices cause CSS drop shadows to malfunction | Next.js

Update: After some testing, I discovered that this issue is specific to iPhones. When I tested it with an android device, everything worked perfectly fine. However, when I tried viewing the page on two different iPhones, it broke on both. This problem see ...