What is the best way to remove horizontal scrolling and reduce element size on mobile devices?

My current project is utilizing the Material-ui framework, and I have a situation where numerous anchor elements are being displayed as a table within a Paper component from mui. However, due to the length of this table, it causes a horizontal scroll bar to appear in the mobile view, which is not ideal. I am looking for a solution that would allow me to reduce the width of these table-like anchor elements so that the horizontal scroll bar does not appear, without resorting to using overflow-x: hidden to simply hide the elements.

Here is a simplified version of my code:

class Row extends React.Component {
  render() {
    const cell = (<a class="linkCell" key={cell.id} href="#"></a>);
      const row = [];
    for (let i = 0; i < 20; i++) {
      row.push(cell);
    }
    return <div>{Row}</div>
  }
}

class WholeTable extends React.Component {
    render() {
  const row = <Row key={row.id}/>
  const table = [];
  for (let i = 0; i < 100; i++) {
    table.push(row);
  }
  return <Paper>{table}</Paper>
    };
}

Current appearance of the issue (before and after horizontal scrolling): https://i.stack.imgur.com/UowXL.png

https://i.stack.imgur.com/8F2DR.png

I would greatly appreciate any assistance or advice on how to tackle this challenge effectively. Thank you!

Answer №1

To achieve responsive sizing in your CSS, consider using the following code snippet:

width: 100vw;

This will make all elements shrink to fit the full width of the viewport. Just remember to adjust for any padding you may have added by subtracting those pixels from the total width.

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

Organizing list items into vertical columns

Could you help me with UL/LI syntax and how to create a wrapping list? For example, I would like to display: 1 2 3 4 5 6 As: 1 4 2 5 3 6 Currently, I have a header, content, and footer all set with specified heights. I want the list to wrap when ...

Ways to refresh a container

How do I update the box below... <div className="container team-member-tasks"> <header className="header-box"> <h1>Team Member Tasks</h1> ...after marking a task as complete using the script below. ...

Content Security Policy prevents videos from loading in React applications

I'm encountering an issue while attempting to showcase a video preview within my React application. The error message states: "Refused to load media from 'data:video/mp4;base64,...' because it violates the following Content Security Policy ...

What is the method to reset the value of an input field within a functional component while avoiding the use of state?

When working with an input field in a functional component and handling the input via onKeyUp to access event.which, things work smoothly until I need to reset the value of the input field. While grabbing the content of the input using event.target.value i ...

Caution: It is important for each child within a list to have a distinct "key" prop when using react-input

I'm currently facing an issue with the following code snippet: {array.map((item) => ( <> <input key={item.id} type="checkbox" /> ...

MUI - The helper text for a Select using a TextField is appearing below the input field rather than within the input field itself

This is how the content will be displayed. https://i.stack.imgur.com/fwvcW.png Displayed below is the code for rendering: <Grid container spacing={2}> <Grid item xs={space} key={1}> <TextField value={""} onChang ...

Using MaterialUI to implement CSS transitions

I am currently working on implementing a MaterialUI theme across my app. Everything is set up properly except for the transition property, which doesn't seem to be working as expected. Although Chrome DevTools show the property as active, there is no ...

The selected value is not displayed in the Material UI select component

My select component is showing the menu items and allowing me to select them, but it's not displaying the selected value. However, its handle function is functioning correctly because when I choose an item, the value in the database gets updated. Bel ...

Is it possible to invoke an action within a reducer function?

I'm attempting to trigger an action in the redaction process and struggling to grasp the concept. ... import { loaderStart, loaderStop } from '../actions/loaders'; const loaders = dispatch => ({ loaderStart: text => dispatch(loader ...

Modifying the appearance of Bootstrap button colors

I recently came across this code on the Bootstrap website. I am curious about how to change the text color from blue to black in this specific code snippet. Currently, the text is appearing as blue by default. For reference and a live example, you can vis ...

Struggling to Make Text Overlay Transparent and Slide Only to the Right

Can someone help me make my image have an opaque overlay with text that slides only right when hovered over? Currently, it's sliding both right and up. Any suggestions on how to fix this issue would be greatly appreciated. Thank you. html, body{ ...

Keep scrolling! There's no need to worry about reaching the end of the page and having to start over

I'm experiencing an issue where scrolling only works once when the page is initially loaded. I need it to be able to repeat from the beginning each time. <div class="content"> <div class="next-section blue">First Section</div> & ...

The position of the HTML class shifts when the window is resized

I am in the process of creating a basic website layout that resembles this design. However, I am facing an issue where the webpage does not adapt well to different window sizes. Specifically, the elements with the classes .gameInfo and .playerList overlap ...

Exploring ways to utilize Next.js (React) for formatting date and time with either Moment.js or alternate

When deciding on the best method for handling date formats in my next front-end app, should I use Moment.js or JavaScript functions? The data is sourced from the backend as the date type, and I want it to be displayed in a user-friendly format while consid ...

The alignment of my text appears to be off

I am facing an issue with the second <ul> on my webpage, which contains more content compared to the first one. In this second <ul>, the last line is appearing floated to the left and does not appear below the penultimate line as expected. Li ...

Why do my tablet media queries take precedence over mobile view media queries?

I've noticed that when I view my website on mobile devices, the tablet media queries always seem to override my mobile media queries. Can anyone explain why this is happening? Here is how I have set it up: /* X-Small devices (portrait phones, less t ...

The Tailwind child element set to 'h-full' is as big as the parent element set to 'h-screen', causing it to appear oversized

My webpage is built using Tailwind CSS and the code for it is as follows: <div id="parent" class="flex h-screen flex-col bg-red-600"> <div id="child1" class="flex h-20 items-center justify-center bg-green-600&q ...

React component showing historical highchart data when navigating through previous and next periods

I developed this element to showcase a Highchart. It's utilized within a dashboard element that I access from an item in a list. It mostly works as intended, but not entirely. When I move to the dashboard for item A, everything functions correctly. H ...

Eliminating the GWT Window Padding in LibGDX

Explanation: I am currently in the process of deploying a LibGDX GWT application to the browser. Challenge: In the image below, you can see the top left portion of my GWT application showcased by the large black rectangle. The issue here is the unwanted ...

Cannot change left and right padding for MUI toolbar without using !important

I am currently working with the Toolbar component in version 5.15.15 of MUI, within the context of a project using Next.js 14 The default right and left paddings of 24px seem to be unoverridable despite my attempts to do so following the documentation pro ...