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

Is it possible to intercept tRPC requests and modify the response data on the client side, either before or after the request is sent?

I'm currently working on creating a sample e-commerce website using Next.js 13, utilizing the app directory and tRPC. So far, I've successfully developed the majority of the admin dashboard and established the core functionality of the site incl ...

Enhancing HTML table interactivity: Updating class of cells upon hover

While attempting to update the class on hover, I noticed that the class changes from 1 to hovering cells However, I want the class to change from 1 to currently hovered cells If moving the mouse from 1 to 10 and then to 2, the currently hovered cells wil ...

What is the best way to use identical styles for 2 different classes at separate breakpoints?

Is it possible to apply a chunk of (S)CSS to two different elements in two different breakpoints to avoid redundancy? I am using Bootstrap 4.6. <div class="one"> <div class="content">Something</div> </div> & ...

What feature in React Native allows the use of local folders as a 'package name'?

Hey there, I have a bit of an odd question that I think you can help me with! So in React Native, you have the ability to create a package.json file within your config folder. The contents may look something like this: { "name": "@config" } After addi ...

How do I automatically redirect a user after they login using react redux?

Currently, I am utilizing react redux in conjunction with Next.js. The goal is to redirect the user to a specific page if they meet certain requirements. I have implemented this logic within my useEffect function and it works as expected. However, upon r ...

Retrieve the nested value of an object using the specified key field

When using the DataGrid component from material-ui to display my data in a table, I encountered an issue with accessing nested values. Specifically, I have a nested array of data but am unable to retrieve the nested value within the datagrid using the key ...

What is the best way to vertically align a label at a 270-degree angle?

I am trying to position text vertically at 270 degrees and in the middle of an image. This is my goal. Despite attempting to use the CSS 'transform' property, I have been unsuccessful. You can view the code I tried here. Below is the HTML and CS ...

The PUT request in the PERN App is failing to reach the Webapp, despite successfully going through in Postman

I recently completed developing a PERN todo application, which marks my first experience in creating an app that integrates a backend with a frontend connected to a database. Despite successfully testing the put request in Postman, I encountered an issue ...

Utilize the React.createContext() method integrated within the _app.js file

I need to retrieve the emailLogin function from my context in a different component: userContext.js import React, { useEffect, useState } from 'react'; import cookie from 'js-cookie'; import {firebase} from './firebase-client&apos ...

Experiment with timeout features in jest and react-testing-library for testing functionality

I'm currently practicing Test-Driven Development (TDD) and I have a scenario where a span element should be displayed on the screen after 5 seconds. However, I haven't actually implemented the span yet, so the test is expected to fail. Surprising ...

struggling to perfect the CSS styling

I am in need of a design similar to the image linked below: https://i.sstatic.net/Er1wT.png I attempted to create this layout using a table, but I have not been successful in aligning the side images properly. testTable.html <style> .container{ ...

An issue arises with webpack-dev-server when running on Windows systems

Seeking assistance with a React project located at https://github.com/ReuvenLiran/Netomedia. Everything runs smoothly on Linux, but encounters an error on Windows: [email protected] start C:\Users\user1\Documents\Dev\Netom ...

Collaborating on components within nested React.js applications

I have a unique situation where I have two React.js apps, one nested inside the other. Both were bootstrapped using create-react-app. The project directory structure is as follows: . +-- admin | +-- node_modules | +-- public | +-- src | +-- p ...

Create stunning HTML emails by incorporating a transparent background color behind images and text

Is there a way to add text on a transparent background layer placed over an image without using the background-image property? In my case, I am working on an HTML Emailer and must utilize the img tag instead. Any suggestions on how to achieve this? < ...

The jQuery plugin functions smoothly when running on localhost, but it causes issues with the background image when deployed on the web

I created a compact plugin to show a cookie message. While testing it on my local machine, everything functioned smoothly without affecting any web pages. However, once I transferred the files to the server, I encountered issues such as: A background ima ...

Adjusting text to begin after a variable by two spaces (equivalent to 5 pixels)

When displaying the echoed text below, I noticed that "DURING" sometimes overlaps with the variable $submittor when there are not enough &nbsp;s. On the other hand, if too many &nbsp;s are added, there ends up being excessive space between $submitt ...

Struggling to locate text within the confines of the meta viewport

So I'm new to this whole blogging thing and I wanted to make sure my site was responsive. I added the meta viewport tag, but when I tested it out on Google Chrome with different window sizes, my text just disappeared! Here's a snippet of the CSS ...

Angular Tag < with CSS styling

Why should we use the angular tag in CSS? For example: .class << span Typically, we use these types of tags: body { background-color:#d0e4fe; } h1 { color:orange; text-align:center; } p { font-family:"Times New Roman"; font-si ...

The color of the text on the Homepage appears differently on iOS Safari

At the top of my homepage, I have displayed the company phone number with white text color. It appears correctly as white on my desktop browsers (Firefox and Chrome), also on my Droid phone, but shows up as dark gray on my iOS phone using Safari. Why is th ...

How can I modify the HTML code for rooms in the HTML 5 client of the bigbluebutton application?

Is it possible to customize the HTML code of rooms within the BigBlueButton source code? Additionally, how can I modify the CSS styles of elements in room sessions? For instance, I am interested in hiding the logo of BigBlueButton by setting 'display: ...