Creating a scrollable container using CSS

I am currently working on a React project and encountered an issue with the CSS styling. I am looking for a solution that allows me to keep the parent and child components the same while enabling a scroll effect on the left side of the div containing shopping items. I have tried using overflow-y: scroll, but it only creates a scroll bar without making the content scrollable, even when I set a specific height. I am aware of another method that accomplishes this, but unfortunately, I am unable to locate it at the moment.

https://i.sstatic.net/8EhdL.png

The parent HTML code:

const CartModal = () => {
  const { totalPrice, totalAmount } = useSelector((state) => state.cart);

  return (
    <div className={classes["cart-modal"]}>
      <div className={classes["cart-modal__navbar"]}></div>
      <div className={classes["cart-modal__body"]}>
        <div className={classes["body__left-side"]}>
          <h1>ORDERS</h1>
          <CartModalFoodList />
        </div>
        <div className={classes["body__right-side"]}>
          <div>
            <img src={BigCart} />
          </div>
          <div>
            <h2>Total price:</h2>
            <h2>{totalPrice}$</h2>
          </div>
          <div>
            <h2>Total amount:</h2>
            <h2>{totalAmount}</h2>
          </div>
        </div>
      </div>
    </div>
  );
};
...and so on.

Thank you.

Answer №1

To specify the height of the division, set a value for the div's height and include overflow: auto;

Answer №2

To enable vertical scrolling, simply add the CSS property overflow-y: scroll to the "main-content__wrapper" class.

.main-content__wrapper {
   height: 100%;
   width: 60%;
   background-color: #f2f2f2;
   padding: 0 4%;
   overflow-y: scroll;
}

Answer №3

To ensure proper scrolling functionality, simply insert over-flow: "auto" into the cart-modal__body class.

Answer №4

The issue has been resolved by making adjustments to .body__left-side

.body__left-side {
  height: 100%;
  width: 55%;
  background-color: white;
  padding: 0 3.5%;
  overflow-y: scroll;
}

I also made corrections to .menu-list

.menu-list {
  height: auto;
  padding-bottom: 25%;
}

Many thanks for the assistance.

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

How can we fix the null parameters being received by the ModelPage function?

I've been learning how to successfully pass values to a Post method using AJAX in .NET Core 6 Razor Pages, but I am encountering some difficulties. Below are the relevant codes: Front end: function calculateSalary() { var dropdown = document.get ...

Ways to dispatch a reducer action without the use of redux saga

Within my project, I have incorporated redux saga. However, I am looking to directly trigger a reducer action from within my component. const mapDispatchToProps = (dispatch) => ({ showUsers: () => dispatch(UserActions.showUsers()), }) Everything ...

Which one has better performance: class or CssClass?

Curious about the efficiency of: <asp:TextBox runat="server" class="someCssClass"></asp:TextBox> as opposed to. <asp:TextBox runat="server" CssClass="someCssClass"></asp:TextBox> I speculate that class is quicker than CssClass s ...

Cannot get the arrow to rotate using Jquery's css() function

Having trouble using css() to rotate my arrow $(function() { $("#arrowAnim").css("transform:","rotate(300deg)"); }); Check out the fiddle here: https://jsfiddle.net/u4wx093a/10/ I've looked for similar issues but can't seem to solve it on my o ...

Having trouble with the Bootstrap navbar on your iPad?

I have a navigation bar on a website I am developing. It is functioning correctly on Windows browsers (Chrome, Firefox, IE), Mac OS browsers (Chrome, Firefox, Safari), and Android browsers (Chrome, Firefox). However, when I try to click on the File menu fr ...

What is the best way to utilize findOneAndUpdate() in Mongoose while maintaining a consistent value?

I have a programming challenge where I need to increment one value if condition x is true, and another value if condition y is true. The issue I'm facing is that my current system also resets the value that is not being updated back to 0, which is not ...

Solving runtime JavaScript attribute issues by deciphering TypeScript compiler notifications

Here is a code snippet I am currently working with: <div class="authentication-validation-message-container"> <ng-container *ngIf="email.invalid && (email.dirty || email.touched)"> <div class="validation-error-message" *ngIf=" ...

Combining numbers of identical precedence levels in JavaScript/jQuery

Suppose I have an array stored as follows: [1,2,3,4,5,6,7,9] My desired output is a string containing: "{1 to 7;9}" Currently, my code looks like this: var _checkbox = [1,2,3,4,5,6,7,9]; for (i=0; i<_checkbox.length; i++) { //if ($($(_checkbox) ...

Tips for patiently waiting for connection.connect

Looking for a way to validate mysql connections. What is the best approach to ensure the connection before proceeding in a function? function _testConnection( _host, _user, _password, _database) { let isConnected = false; let connection = mysql.cr ...

Problem saving videos when using the right-click function

Hello, I am currently working on retrieving videos from a database, but I have encountered an issue with the video saving option. When a user right-clicks on the video, they are able to save it in their system's storage. What I would like to achieve ...

Leveraging the while/for loops for the purpose of reading exactly two lines of input

I'm facing a challenge that involves handling two lines of input data. Input : 4 6 | 6 9 Output : 2 | 15 (the "|" signifies a line break) However, I am unsure about the best approach to interpret these two lines effectively. I attempted using a f ...

Bootstrap 2.0.3: Accordion Collapse feature no longer functioning

Previously, my accordion functioned perfectly with Bootstrap 2.0.2, utilizing data-toggle="collapse" and data-parent="#selector". However, after upgrading to version 2.0.3, the accordion stopped working as expected. While it still opens and closes the des ...

Using Jquery to iterate through a dynamic list of elements

Currently, I am exploring the idea of creating a forEach loop that can handle an unspecified number of elements. The goal is to randomly select one element, perform XYZ actions on it, make it visible, and then eliminate it from consideration. This process ...

Creating a predictive text feature using AngularJS and jQuery

Currently, I'm developing a web application that utilizes: JQuery AngularJS Kendo framework Specifically, I am tasked with implementing an auto-complete feature using Kendo on an input text field. Initially, my approach was to target the inp ...

Using `preventDefault()` does not stop the action from occurring

Whenever I apply event.preventDefault() to a link, it works perfectly fine. But when I do the same for a button, it doesn't seem to have any effect! Check out the DEMO This is the code snippet in question: <a id="link" href="http://www.google.co ...

transmit the information contained in the request

Within this code snippet, I am facing an issue with sending data to the request. The data being sent is present and visible in the console, but the problem arises when it comes to the "slice" file. It seems that the file is unable to receive the data and i ...

Problems with WordPress Theme Rendering in Outdated Versions of Internet Explorer

Currently, I am developing a website for Chase on the Lake at http://chaseonthelake.com/. While everything looks perfect in FireFox, there are some display issues when viewing it in Internet Explorer. The dropdown transparency is not showing correctly, m ...

Tips for incorporating icons into your navigation drawer

I have successfully added Icons to a custom drawer navigation, but I am curious if it is possible to directly include icons in </Drawer.Navigator> or <Drawer.Screen/> without the need for additional customization? Below is an example of my cur ...

Blend the power of Dynamic classes with data binders in Vue.js

Recently, I've been working on a v-for loop in HTML that looks like this: <ul v-for="(item, index) in openweathermap.list"> <li>{{item.dt_txt}}</li> <li>{{item.weather[0].description}}</li> <li>{{item.w ...

Customize Zurb Foundation: Applying styles to specific child elements based on current screen size (large, medium, small)

For wide displays, I aim to give a distinct border to each 7th element. However, on smaller screens, I wish to apply these styles to every 4th element instead. Is there a way for me to nest my styles within .small, .medium, and .large classes? ...