FlexBox responsive items that are expandable getting cut off

I am currently working on creating a row of expandable items. While I have almost achieved the desired behavior, there are a few issues that I need help with:

  1. On Desktop, the items are cut off and not fully visible.
  2. On Mobile, half of the items are missing and cannot be scrolled to.

Here is how it looks like (imgur)

The problems stem from my Flex setup and how I manage it. I recently grasped the basics but now need to understand the interactions between different properties better. Any explanation alongside a solution would be greatly appreciated!

This is the Card that holds these items (written in kotlin):

  val x = { props ->
             // this is the Card
            return@fc div("w-full flex flex-col items-center shadow-lg p-4 rounded-lg lg:shadow-none") {

                // This is the container holding the items
                div("flex w-full gap-3 overflow-x-auto items-start justify-center my-5 snap-x p-2") {
                    model.content.forEachIndexed { index, item ->
                        ModeratedContentItem {

                        }

                    }

                }
            }
        }

And here are the items:

return@fc div("w-full shadow-md rounded-md " +
            "items-center max-w-sm flex-initial lg:shrink-0 snap-center " + if(expanded) " flex-none " else " shrink ") {
 ...........

The concept is for the items to enlarge on desktop and shrink gradually on smaller screens, then expand again when needed. However, playing around with shrinking and flex seems to mess up the scrolling functionality.

According to my understanding of FlexBox workings, this setup should function correctly. I'm unsure why the scrolling behaves unexpectedly while experimenting with shrinking and flex properties.

EDIT: Adding Justify Content Center to the item container is causing most of the issues.

I aim to have the items start from the center (especially when there are fewer items) and by using items-start, ensure that expanded items do not affect others and remain connected to the top.

EDIT: Codesandbox link provided here, although it doesn't work well on mobile, it showcases the desktop issue accurately.

You can observe that when multiple items are present, the parent container stretches. If you expand one item, the parent container adjusts to the correct size, but the reason behind this behavior remains unclear.

Answer №1

After encountering a frustrating bug, thankfully applying the solution suggested in the article resolved the issue

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

A blank screen of errors pops up when attempting to update through a form

Encountering a white error screen when attempting to add an item using a form in Python / Django. I'm currently debugging the issue but lacking information. Any guidance on where to look next would be greatly appreciated. Models.py from __future__ i ...

modify the color of a box within a grid upon clicking it

I am curious if it is possible to change the color of a box when it is clicked. I am working on coding a "calculator layout" and would like to start with this part 1 2 3 4 5 6 7 8 9 0 This is what I have been working on and struggling with. $(docume ...

Is there a way for me to immediately send data after receiving it?

When I try to perform onPress={() => kakaoLosing() I am attempting to retrieve data (profile) from getProfile using async await and immediately dispatch that data to KAKAOLOG_IN_REQUEST, This is my current code snippet: import { ...

React and Actix: The requested resource does not have the 'Access-Control-Allow-Origin' header present

When using React, I call an Actix API async function requestsFn() { try { const response = await fetch('https://exampleip/requests', { method: 'GET', headers: { Authorization: sessionStorage.getItem('auth0 ...

The command `node server.js` has been initiated. Nodemon has executed a clean exit and is now waiting for any

A React application has been developed where users can input their email and a message to send to the server. However, upon trying to send the message, Error number 2 is encountered along with viewing Error number 1 in the terminal. Despite ensuring that ...

New update in Next.js version 13.4 brings a modification to routing system

I'm currently working with Next.js 13.4 and an app directory. I'm trying to implement a centrally located loader that will show whenever there is a route change anywhere within the app. Since routes/navigation don't have event listeners, I&a ...

Create a personalized notification pop-up complete with a text field in a React Native application

Is there a way to design a window with an input field that pops up upon pressing a button? Greetings! I am interested in learning how to create a unique custom alert window that includes an input field. Ideally, this window would open when a specific butt ...

The issue with dynamic sizing in React and Tailwind is that it does not consistently work with arbitrary sizes. Some sizes do not appear properly, causing items to

In this code snippet, I am attempting to create a circle component of dynamically sized using html div and Tailwind CSS w-[diameter] & h-[diameter] attributes in a create-next-app@latest project. However, the circle fails to render properly with certa ...

What is the most efficient method for transferring ASP.NET form data to an Excel spreadsheet?

I am confident that exporting data from my web form should be achievable, but I'm not quite sure of the steps involved. My web form contains numerous select dropdowns and input boxes. Could anyone guide me on how to export the data from these asp co ...

What is the best way to generate an array of imported images within a React Component?

I am looking to optimize the loading process for nearly a hundred images in my React component by importing them all via a single statement from another JavaScript file. However, before I can achieve this, I need to find a way to store all these images in ...

React build failing to load exotic filetypes

I set up a project using create-react-app and I am trying to incorporate file types such as webp or mp3. Everything works perfectly when I run my application on localhost with npm run start, but once I deploy it on my server (using npm run build and serv ...

Material UI - Clear all designs from the slate

Is it possible to completely override all default material-ui styles and implement your own custom style guide for components? This would involve removing all material-ui styles and starting fresh with customized html skeletons. Creating a new theme with m ...

The JavaScript string in question is: "accepted === accepted && 50 > 100". I need to determine whether this string is valid or not by returning a boolean answer

I am developing a dynamic condition builder that generates a JavaScript string such as, tpc_1 === accepted && tpc_6 > 100 After the replace function, the new string becomes, accepted === accepted && 50 > 100 Now my challenge is to va ...

What is the best way to insert an image in front of text within a table cell that can be identified by its class name?

JavaScript Question: function addFlags(){ while(i < $('.tabledata').length){ var current_val = $('.tabledata').eq(i).text(); arr.push(current_val); $('.tabledata').eq(i).html("<img s ...

Front Page Luma Design for Magento Platform

As a newcomer to Magento, I am currently using the Luma Home Page which appears blank. My goal is to incorporate an image that spans the entire browser viewport. Is it possible to achieve this through the admin panel by adjusting the CSS within the home pa ...

What is the method for displaying map tooltips by default rather than on mouseover?

Currently, I have a script set up to display a map with two markers. Whenever I hover over one of the markers, a popup tooltip appears with location information. My question is, how can I make the information appear by default without needing to hover ov ...

Hyperlink -> Boundary

Our homepage features various elements as part of the menu. Each element consists of a picture, title, and small description. The issue is that these menu items always display a border when the mouse hovers over them, despite attempts to hide it. You can ...

Deploy exclusively the compiled materials of a Next.js undertaking

I have a Next.js project that I want to deploy using a Docker image. Is it feasible to use an existing dist folder (.next) and directly start the next.js server (npm run start) without rebuilding it within the container? The Docker container will be runni ...

Exploring a different approach to utilizing Ant Design Table Columns and ColumnGroups

As per the demo on how Ant Design groups columns, tables from Ant Design are typically set up using the following structure, assuming that you have correctly predefined your columns and data: <Table columns={columns} dataSource={data} // .. ...

Guide to monitoring only one specific property within an object using the useEffect hook

const LanguageProvider = ({ children }) => { const [state, dispatch] = useReducer(reducer, { locale: DEFAULT_LOCALE }); useEffect(() => { const storedLocale = getStoredLocale(); if (storedLocale) dispatch(changeLocale(storedLocale)); } ...