Unable to reach the end of the left edge while scrolling horizontally using CSS

Struggling with a horizontal scroll in React using CSS. Trying to showcase a list of cards horizontally, but can't get the left edge to display properly. Attached is a screenshot highlighting the issue. The first card in the list is not displaying correctly. Using ant design to create the cards.

https://i.sstatic.net/reRaY.png

Below is the JavaScript and CSS code for that section:

<div className={styles.subjectArea}>
 <Card
    hoverable
    style={{ width: '219px', height: '248px', margin: 10, borderRadius: '10px', textAlign: 'center', fontWeight: 'bold' }}
    cover={<img alt="example" src="https://i.pinimg.com/originals/bc/4f/e5/bc4fe5e81c387c9c1c0144caf0299ba9.jpg" style={{ objectFit: 'cover', height: '180px', borderRadius: '10px 10px 0px 0px' }} />}
    >
     <Meta title="Science" style={{ fontWeight: '900', margin: '-10px 0px -100px 0px' }} />
    </Card>
    //Other cards removed for simplicity
</div>
.subjectArea {
    padding: 20px;
    min-width: 100%;
    min-height:  300px;
    background: #FFFFFF;
    border: 1px solid rgba(133, 77, 206, 0.25);
    box-sizing: border-box;
    border-radius: 8px;   
    display: flex;
    justify-content: space-around;
    align-items: center;
    overflow: auto;
    overflow-y: hidden;     
    margin-top: 20px;
}

Any suggestions on how to ensure the first card is fully visible when scrolled to the left?

Answer №1

Give this code a try, it should work for you

 <div class="contentArea ">
  <div class="container">
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
  </div>
</div>

.contentArea {
    padding: 20px;
    max-width: 700px;
    width : 100%;
    display : flex;
    min-height:  300px;
    background: #FFFFFF;
    border: 1px solid rgba(133, 77, 206, 0.25);
    box-sizing: border-box;
    border-radius: 8px; 
    align-items: center; 
    margin-top: 20px;
    overflow-x : scroll;
}

.box{
  width : 200px ;
  height : 280px;
  margin : 0px 20px;
  background : #000;
}
.container{
  display : flex;
}

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

Changing styles with the use of bootstrap.css themes on the fly

I'm experimenting with toggling between a custom dark and light theme in my MVC application. On the _Layout.cshtml page, the default theme is loaded by the following code: <link id="theme" rel="stylesheet" href="~/lib/bootstrap/dist/css/Original. ...

Alter the appearance of a webpage by pressing a key. (Using Vue.js)

Is there a way to change the CSS style value of an element when a specific keybind is pressed by the user? <textarea id="check" v-model="text" v-on:keydown.ctrl.up="decreaseFont" > I am able to confirm that the ...

Tips for making a screen adapt to different monitor resolutions

Hello there! I've been working on a login screen using bootstrap 4, but I'm facing an issue with the layout. My concern is about adjusting the page layout so that the background image does not get cut off or distorted. Take a look at the image ...

Increase the size of clickable hyperlinks in CSS

I am looking to increase the clickable area of my menu links. Currently, only a small part of the links is clickable and I want to know how to expand it. I have seen some CSS tricks using classes, but I also have an active class for these links. Can you ...

The animated element in React is not running despite the animation class being added through addEventListener

When I add an animation class triggered by a scroll event listener, the progress bar animation only runs once on page load and does not run again when I scroll. Is there an issue with the code or is setState being used incorrectly? .body2 { background ...

The mobile application on iPad only supports rotating in three specific directions

There seems to be an issue with the app not rotating when my iPad is in portrait mode, with the home button at the bottom and the camera at the top. However, rotation works fine in all other directions - landscape and portrait (when the camera is on the bo ...

Having trouble with showing dynamic data in column2 of my HTML layout, and the alignment doesn't look quite right in HTML

I'm working with this HTML file, attempting to create a two-column layout using HTML and CSS. I want one column to be labeled REQUEST and the other RESPONSE. When a value is entered in the text field in Column 1, it should display a response in Column ...

Class-based React components are able to correctly update their state by referencing the previous state

In my React application, I am utilizing class based components. There is a checkbox that passes a string and a number value when it is checked. Currently, the state in my application looks like this: state = { checked: [], checkedWeight: 0, }; ...

What is the best way to design a Bootstrap grid layout that includes a responsive left column with a minimum width and a scrollable right column?

I'm so close to getting the desired look and behavior, but I'm facing a problem with the scrolling in the right column. The scrollbar is visible but it's not scrolling the content on the right side. It should look like this: . Currently, i ...

Using Bootstrap and CSS to style a div element and fill it

I'm struggling with a div that splits in two, where I've placed an image on the left side. However, the image doesn't seem to fill the entire space and there are empty spaces on the sides. I'm using bootstrap, but any CSS solution would ...

z-index in CSS causes links to conflict

I am currently working on a project that requires an image to be displayed prominently on the website along with some links positioned behind it. However, I'm facing an issue where I can't click on the links after implementing z-indexes to layer ...

Whenever I try to retrieve a file from my backend using formData.get('file'), the FormData functionality inexplicably sends back a null value instead. Even though I

I am encountering an issue while trying to send a file to parse to my backend using Flask. When I send the file using Postman, it works correctly. However, when I attempt to send it through my React app, it does not go through. <div ...

How to apply a CSS style to a specific class based on conditions in Vue.js

Many questions have been asked about conditionally adding classes or styles to elements, but I want to take it a step further and conditionally style a class. In my application, users can customize foreground and background colors using a theming system. ...

Although IE may have issues, @font-face is not functioning properly in Chrome and FireFox

Hello, I've encountered an issue with implementing @font-face in CSS. It seems to be working properly in Internet Explorer, but it has no effect in FireFox and Chrome. I am trying to add a custom font to my website by placing the files Snazanin.ttf an ...

Having trouble resolving '@material-ui/lab/AdapterDateFns' for Material UI Lab's date picker

Encountering resolution issues with '@material-ui/lab/AdapterDateFns' Struggling to resolve '@material-ui/lab/DateTimePicker' Unable to resolve '@material-ui/lab/LocalizationProvider' Despite having installed @material-ui/l ...

``Can you provide steps on how to update the value of a button when

I am attempting to create a button that has a default value of '', and when clicked, its value should change. Here is my current approach. First, I created a new hook state that initializes the value as '': const [buttonValue, setButto ...

"Exploring the Mini Drawer feature on Material UI brings up a whole new page for the Link

Currently, I am working on a project that involves updating stocks using Material UI. I have implemented a mini drawer from Material UI, but when I click on the menu link, it routes to a new page instead of rendering on the homepage itself. In my App.JS f ...

The default value of react-hook-form does not get updated by useEffect when setting up an edit form

When I try to populate the values of material-ui datepicker fields while rendering the edit form component, I encounter an issue. The console shows that the date object is being created correctly, but it's not passing to the state as expected. I' ...

I am facing difficulties installing libraries in my react-native project

Maybe the issue lies within cocoapods or there's a problem in my JSON. Oddly, no errors are showing up in the code. Whenever I attempt to install any library using yarn, I encounter this: purrweb@192 awesomeProject % yarn add react-native-image-pi ...

Creating a persistent table header and first column in HTML tables

I am having trouble getting the header column to stick to the top along with the first column beneath it. Here's what I'm aiming for: https://i.stack.imgur.com/hzVt8.png Despite my efforts, I can't seem to make it work. I've experimen ...