I am dealing with a set of divs wrapped in a flex container that tend to overlap each other. Their heights vary and sometimes they wrap multiple times. Any suggestions on how to prevent this

I am encountering an issue where the width of the div remains the same after it has wrapped, causing overlapping. I want the first div to push the second to the right and so on.

When I add a 100% width, it makes the width for the smallest div the same as the largest, leaving space on either side.

The columns are iterated over using {orderedColumns.map((column, index) => { return ( ); })}

<div style={{ display: "flex" }}>
       <div
         style={{
           height: "60px",
           display: "flex",
           flexDirection: "column",
           flexWrap: "wrap",
           overflowX: "visible"
         }}
       >
         <div>Test1</div>
         <div>Test1</div>
         <div>Test1</div>
         <div>Test1</div>
         <div>Test1</div>
       </div>
       <div
         style={{
           height: "60px",
           display: "flex",
           flexDirection: "column",
           flexWrap: "wrap",
           overflowX: "visible"
         }}
       >
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
         <div>Test2</div>
       </div>
       <div
         style={{
           height: "60px",
           display: "flex",
           flexDirection: "column",
           flexWrap: "wrap",
           overflowX: "visible"
         }}
       >
         <div>Test3</div>
         <div>Test3</div>
         <div>Test3</div>
         <div>Test3</div>
         <div>Test3</div>
       </div>
     </div>

If you have any suggestions, they would be greatly appreciated.

Thank you.

Answer №1

When working with Flexbox columns, the parent's width remains constant even when items wrap, which may be causing your issue. For more information, you can refer to this discussion on Stack Overflow: When flexbox items wrap in column mode, container does not grow its width.

It seems unlikely that you'll achieve the desired layout using flexbox columns since the parent element cannot accurately determine its width due to this limitation.

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

Efficient Django Template: Accurate Conversion of Values through Dictionary Searching

I have an object with an attribute that has specific choices defined in its class: class StashURLJobRequest(models.Model): STATUS_CHOICES = ((0,"Requested"),(1,"Done"),(2,"Failed")) url = models.URLField() created = models.DateTimeField(auto_n ...

On a Samsung tablet with Moodle, the body background image is set to display at the top

Encountered an issue with Sambungs tables. I have a background image set on the body. Here is how the CSS looks: html, body{ background: url('img/background.jpg') no-repeat; background-position: top; // I also tried cover, fixed, etc } The ...

Vue unable to load material icons

The icons npm package "material-icons" version "^0.3.1" has been successfully installed. "material-icons": "^0.3.1" The icons have been imported as shown below. <style lang="sass"> $material-icons-font-path: '~material-icons/iconfont/'; ...

How can you utilize CSS grid to position an alternate symbol alongside ordinary text?

Does anyone have suggestions on how to align an "alt symbol" with "regular text"? I'm struggling to center both elements without resorting to hacky solutions. Currently, I am using CSS grid, but I am open to exploring other solutions that are easy an ...

Changes made to the data are not reflected in the user interface, but they are visible in the console

When working on a React project with input fields, I encountered an issue where the date data can be changed but doesn't get reflected in the UI. Instead, the updated data is visible in the console. The code snippet below showcases how I'm using ...

React-MobX issue: A boolean value is required for the 'decoratorsBeforeExport' option in the 'decorators' plugin

I encountered an error message stating: To migrate from Babylon/Babel 6 or utilize the old decorators proposal, it is recommended to use the 'decorators-legacy' plugin instead of 'decorators'. package.json "@babel/plugin-proposal-deco ...

Adjust the color of static hyperlinks based on the background color

Is there a way to dynamically change the color of my fixed side links based on the background color when scrolling? I attempted to use CSS mixed-blend-mode: difference, but it does not provide the level of control I need. Therefore, I am looking to achieve ...

Using Material-UI's <Autocomplete/> component and the getOptionLabel prop to handle an empty string value

Currently, I am working with material-ui autocomplete and passing an array of states to its options property. However, I have encountered an issue with the getOptionLabel method: Material-UI: The `getOptionLabel` method of Autocomplete returned undefined ...

Mastering the Art of Aligning Avatars: Effortless Right Alignment

Here's the updated version of the navigation bar: <nav class="navbar navbar-expand-md navbar-dark bg-dark static-top"> <button class="navbar-toggler" type="button" data-toggle="collapse"> ...

react-i18next is throwing a missingKey error only during the build process

https://i.stack.imgur.com/cicuW.png My code includes index.js and i18next.js(the configuration for i18n) index.js import React, { Suspense } from 'react' import i18n from './i18next' import './i18next' import ReactDOM from & ...

Issue with Safari not displaying properly when using float:left and float:right (works fine in Firefox and Chrome)

My website has a left side column and a right side column, which display correctly in Firefox and Chrome. However, I am experiencing issues with Safari. Any insights on what could be causing this problem and why it only occurs in Safari? View the code on ...

Making an AJAX call in React JS

I'm currently in the process of creating a dashboard application using reactredux. Coming from an angular background, I find myself feeling a bit lost here. What I need help with is figuring out how to fetch data from an API to display in graphs on th ...

What other options are available besides componentDidUpdate for retrieving the chosen date from a date picker and including it in an API request?

Currently, I am utilizing react-dates to implement a datepicker feature. Whenever the user modifies the date, it updates a prop that is then sent to the backend as a parameter in a query to fetch specific results for that particular day from the database. ...

A guide on accessing the content of two p tags in React by utilizing the useState hook in ReactJs

I am currently working on retrieving the values of two p tags simultaneously to send those values to the backend. This is my useState declaration: const [isProposal, setIsProposal] = useState({ contractorName: "", newProposal: "" }); c ...

Managing form state in React using the Context API allows for easily clearing the form after submission

Looking for assistance with my Expense Tracker application that interacts with a mongoDB backend. I'm utilizing the context API and material UI components for forms, but struggling to clear text fields after form submission. Being new to React and Jav ...

Creating a progress bar that includes hyperlinks: A step-by-step guide

Currently, I am in the process of developing an application form that consists of 9 pages of questions. Initially, I had implemented a progress bar which indicated completion by filling up 1/9 for each page completed. However, I have been informed that thi ...

Some elements are not responding to margin-top properly

I am facing a problem where 2 elements are not responding to the specified margins of margin: 260px 0 0 0; or margin-top: 260px;. Despite inspecting the elements in IE's dev tools and confirming that the margin is set, the elements appear at the top o ...

What causes a header to appear transparent when it has a background color set in HTML?

I'm attempting to create a webpage that resembles Gmail. I have a header with a background color, but when I scroll, the content in the body becomes visible. Here is the view without scrolling: https://i.stack.imgur.com/UQ2sO.png However, while scr ...

Unable to turn off X-Powered-By: Express

After attempting to use app.disable("x-powered-by"); without success, I came across some helpful posts on the topic: how to remove X-Powered-By in ExpressJS Can't get rid of header X-Powered-By:Express I am using "express": "^4.16.4" as backend a ...

I'm having trouble with my dropdown navigation menus - they keep popping back up and I can't seem to access

My website is currently in development and can be accessed at: The top navigation bar on the homepage functions properly across all browsers. However, there are three sections with dropdown submenus - About Us, Training, and Careers. These dropdown submen ...