Flex basis unexpected vertical overflow is not anticipated

I encountered an issue with my code snippet below:

export default function Home() {
  const lists = ["List A", "List B", "List C", "List D"]

  return (
    <div className="flex gap-3">
      {lists.map(list => {
        return <div key={list} className="grow-0 shrink-0 basis-80 bg-red-200">{list}</div>
      })}
    </div>
  )
}

The width of each list is fixed at 20rem (basis-80) and functions properly. However, when I add too many lists, a horizontal scrollbar appears as expected. Surprisingly, there is also vertical overflow along with horizontal overflow. The images illustrate that the lists occupy only a fraction of the vertical space.

No horizontal overflow https://i.sstatic.net/PYaW6.png

Both axes overflow, though I anticipated only horizontal overflow. https://i.sstatic.net/AzaXE.png

Answer №1

To eliminate the issue of vertical overflow, one effective method is to adjust the overflow-y property within the container element by setting it to hidden. By doing so, you can prevent the appearance of a vertical scrollbar.

Consider incorporating the code overflow-y: hidden; into the CSS of your container element as a potential solution.

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

Encountering an error when retrieving data in React: Uncaught (in promise) TypeError - Unable to fetch data

I have recently built a backend using Express and MongoDB database. I am encountering an error while trying to fetch data in React. Could someone please advise on the solution to this error and guide me on how to successfully retrieve data from the backend ...

Is there a way for me to recreate the appearance of the outline and labeling found in Material-UI's outlined textfield?

Can anyone help me figure out how to hide the border behind the title text in an outlined textfield from Material-UI that I am trying to imitate? In the image below, you can see "Due Date/Time" taken from Material-UI library where the title hides the bord ...

When removing a react component from the list, it results in the deletion of all other components within the same

Whenever I click a button, a new component is added to my list of components. Each component in the list has a delete button, which can remove the component from the list. https://i.sstatic.net/uH42y.png Each component, consisting of the text "New Item" ...

Modify the Full Calendar top navigation to display a list of items instead of buttons

Currently working with FullCalendar, I have a couple of tasks that I'm looking for the best solution to: I need help repositioning the right header all the way to the left Right now, the header options are shown as inline-block buttons. I would like ...

Utilizing a function as a value in React state (setState) compared to defining state with constructor in a class and utilizing a state object

Can someone help me understand the concept of state in React better? I'm confused about the differences between these two implementations: This: class Todo extends ... { constructor (){ super() this.state = { ... } } } And This: class Todo extend ...

Sending an HTTP request from a React application to an API hosted on the local server

My primary PC is running a react app on http://localhost:3000, along with a nodejs and express API on http://localhost:3001. The react app successfully requests data from the API on the same machine. However, when I try to access the react app from a dif ...

Achieving consistent width for flex items in each row

Can I ensure that all flex items have the same width? Currently, my code looks like this: .video-container { background-color: blue; min-height: 90vh; display: flex; flex-wrap: wrap; } .video { flex: 1 0 25%; } <div class="video-contain ...

Guide to changing the class of a particular child element when the parent element is clicked with vanilla JavaScript

Upon clicking the parent button, a class within its child element will toggle to show or hide. If the child element is selected, a loading animation will appear for a brief moment before reverting back to its original hidden state. I attempted to achieve ...

Spacing Issue with Material UI Gap Placement

Currently, I am implementing Material UI 5 within a React project using the following code snippet: <Stack> <Stack flexDirection="row" justifyContent="center" padding={4} spacing={{ xs: 4 }} ...

Is there a way for me to retrieve the names of these objects?

In this code snippet, I have utilized an object and am looking to retrieve both its name and value. However, despite my efforts, I have not been able to successfully access the value and name within my handleChange function. const [location ...

Displaying user input data in a separate component post form submission within Angular

I recently developed an employee center app with both form and details views. After submitting the form, the data entered should be displayed in the details view. To facilitate this data transfer, I created an EmployeeService to connect the form and detail ...

There seems to be a styling glitch with Material UI. Both the text and bottom navigation are

Struggling to build a basic website featuring bottom tabs and a drawer, I encountered two main issues. Firstly, despite being logged in the console as clicked (0,1, etc...), the color of the selected bottom tab does not change as expected. Additionally, th ...

How to Left Align Div Centered Within Another Div?

I've encountered an issue with centering icons in my HTML code. Despite trying to fix it myself, the icons always appear left-aligned. I would greatly appreciate any assistance from the helpful members of this community. It's likely a simple fix ...

What causes the off-canvas menu to displace my fixed div when it is opened?

Using the Pushy off-canvas menu from GitHub for my website has been great, but it's causing some trouble with my fixed header. When I scroll down the page, the header sticks perfectly to the top, but once I open the off-canvas menu, the header disappe ...

Express and Webpack Error: "SyntaxError: Unexpected token <"

I am facing difficulties while testing my React webpage that I built using Webpack. When trying to run an Express server, the localhost page appears blank with a console message saying Uncaught SyntaxError: Unexpected token <. It seems like the webpage ...

Include a new element immediately after the user begins typing in the input field

Recently, I figured out how to dynamically add an item based on the state. As the user types something in the input field, it generates list items based on the state mapping. Here's a sample code snippet: return ( <div className="App&qu ...

Arrange the two buttons in a vertical position

Excuse any weak code you may come across, as I am a backend developer. This is the current appearance of my form: The alignment of these two buttons in Chrome is not correct The issue only occurs in Chrome, with FireFox and Edge displaying the form as e ...

Is it possible to eliminate the border on an image input button?

Here is the code I've been working on: HTML: <!DOCTYPE html> ... <form> <input type="image" value=" " class="btnimage" /> </form> ... CSS: .btnimage { width: 80px; height: 25px; background:url('C:/Users ...

Using React with the powerful combination of Superagent and Bluebird Promise, along with

Recently, I've been exploring ways to include headers with superagent bluebird promise in my React project. That's when I stumbled upon superagent-promise-headers (https://github.com/doron2402/superagent-promise-headers) and it seems promising. ...

The requested operation is not supported: ENOSYS

After facing the same error repeatedly while trying to install React JS, Next JS, and Gatsby on my Raspberry Pi 4 running Raspbian, I decided to switch to using Yarn for installing Next.js. However, even with Yarn, npm, and npx attempts, the error persiste ...