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

Utilizing JavaFX 2 with a touch of CSS styling

Currently, I am practicing JavaFX 2.0 and working on creating an XYChart with 2 line series while also customizing colors, strokes, etc. through a CSS file. In order to guide me through this process, I decided to refer to the following link: http://docs. ...

Guide on using jQuery to replace the applied css of an aspx control

My dilemma revolves around an AspxFileManager. I am attempting to distinguish a file when it is loaded by adding a class that places a border around the element. My initial attempt using .attr('style', 'border: 10px!important'); was uns ...

Troubleshooting column alignment with Bootstrap4 and Angular: Resolving issues with text alignment on

Being relatively new to Bootstrap 4, as I have only used version 3.3 on my previous project which did not utilize the flexbox grid system. Now that I am embarking on a new project, I find myself facing a challenge: I am struggling to apply the "text-alig ...

Which is Better for Creating DropDown Menus: CSS or JavaScript?

Starting a new project that involves dropdown menus with categories and subcategories within them. I'm curious about the advantages of using CSS3 only menus compared to traditional JavaScript ones. There are several jQuery menu options available as we ...

Synchronizing CSS3 Animation Events and Event Listeners in jQuery: A Complete Guide

I've been exploring different ways to utilize CSS3 Animation Events and Event Listeners across browsers for more precise control over CSS3 animations. While I know it's possible, I'm struggling to implement it due to my current limitations d ...

Guide on integrating Twitter Pixel with Next.js

Is there a way to incorporate a Twitter pixel into next.js similar to how the Facebook pixel is included? !function(e,t,n,s,u,a) {e.twq || ((s = e.twq = function () { s.exe ? s.exe.apply(s, arguments ...

The challenge of overlapping elements in jQuery UI resizable

Encountering an issue with the resizable class in jQuery UI (http://jqueryui.com/resizable/). When resizing begins, all divs below move to overlap with the resizing div. Upon inspecting the js console in chrome, it appears that resizable applies inline sty ...

maintaining the alignment of one div's right boundary with another div's right boundary

---------------------- ----------------------------->edge X | | | | | logo | | dropdown menu ...

The vertical-align property fails to properly align the list-style-image with the text

My HTML list is structured like this: <ul id="remove"> <li id="rm_txt_1" onClick="remove_1();">Remove </li> </ul> <ul id="move"> <li id="mv_txt_1" onClick="position();">Move Down</li> </ul> It is styled u ...

The website is failing to extend and reveal content that is being concealed by jQuery

I'm currently diving into the world of Javascript and jQuery, attempting to create a functionality where upon clicking the submit button, the website dynamically expands to display search information. Although the feature is still in progress, I am ut ...

"Learn how to create a scrolling div using a combination of CSS and JavaScript with absolute and relative

After relying solely on "pre-made" components like Mui or TailWind, I decided to create a component using only CSS and maybe JavaScript. However, I encountered some difficulties when attempting to position a div inside an image using relative and absolute ...

Delete the line height (or leading) for bigger text in CSS

Is there a way to eliminate the space above and below the mandatory span, specifically when using << within it? The height of the field row is determined by the default line-height for the text size, but the mandatory field is taller due to its larg ...

Connecting JavaScript and jQuery scripts

Help needed! I am a beginner in the world of jQuery and JS. Unfortunately, my JS/jQuery code is not running and I can't figure out why. Can someone please take a look at my HTML and guide me on what might be causing the issue? Do I need to add some ad ...

Exploration of the "display: none;" property and loading of content

I am struggling to find concrete information on how "display: none;" affects content loading. I have always believed that certain browsers do not load external resources within content that is styled with "display: none". Is this still inconsistent across ...

Is there logic in developing a web application using a combination of a NestJS backend and Next.js frontend, along with authentication features?

Currently, I am embarking on the journey of developing a web application using React and Next.js. With my previous experience in backend development using NestJS, I decided to integrate it into this project as well. However, I am unsure if separating the f ...

Toggle the visibility of a div element and smoothly scroll to it on the page

Upon clicking the form, my goal is to show or hide it and scroll down to view the form. The current code I have in place seems to work after the first click. However, on the initial click, it shows the form but fails to scroll down. Any insights on what I ...

What is the best approach to retain a user's selection for dark mode?

I have created a small website to showcase my work, but I'm struggling to figure out how to make the website remember a user's choice of dark mode. After searching on Stack Overflow, I came across suggestions like using cookies or localStorage. ...

Font file not found by Next.js

I'm struggling to implement local fonts in next.js using the localFont function. Here's what I have so far: const Eina = localFont({ src: "../public/fonts/eina01.ttf", }); Unfortunately, no matter where I place the eina file or what ...

When I hover over div 1, I am attempting to conceal it and reveal div 2 in its place

I need help with a CSS issue involving hiding one div on mouse hover and showing another instead. I attempted to achieve this using pure CSS, but both divs end up hidden. Would jQuery be necessary for this task? Below is the CSS/HTML code I wrote: .r ...

"Incompatibility between Tailwind and NextJS causing avatars to disappear when certain props are applied to the render

Encountering issues with the avatar size - changing it to 28, 18, or 16 works fine. However, when adjusting the size to 24, 22, 20, and other values, the image disappears. Below are my screenshots and code snippets: Img Component: import Image from " ...