The scroll bar goes beyond the page boundaries

I am encountering a scrollbar issue with a bootstrap list group on my single-page website. Despite setting the page to occupy 100% of the view using flexbox, the scrollbar is extending beyond the view, and the html/body scrollbar is being utilized instead.

Previous attempts to resolve this problem have been unsuccessful, including reviewing these queries:

Page extends past edge of screen

How can I combine flexbox and vertical scroll in a full-height app?

html,
body {
  height: 100%;
  overflow: hidden;
}

.min-100 {
  min-height: 100%;
}

.sideBar {
  overflow-x: hidden;
  overflow-y: scroll;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbd9d4d4cfc8cfc9dacbfb8e958b958b">[email protected]</a>/dist/css/bootstrap.min.css">
  <style>
    html,
    body {
      height: 100%;
      overflow: hidden;
    }
    
    .min-100 {
      min-height: 100%;
    }
    
    .sideBar {
      overflow-x: hidden;
      overflow-y: scroll;
    }
  </style>
</head>

<body>
  <div class="container-fluid min-100 d-flex flex-column">
    <div class="row flex-grow-1 d-none d-md-flex">
      <div class="col px-0 list-group list-group-flush h-100 sideBar">
        <a class="list-group-item text-dark p-3" style="background-color: rgba(0,0,0,.03);">
          <div class="d-inline-block float-start position-relative me-3">
            <img class="" src="https://avatars.githubusercontent.com/u/48397556?v=4" style="max-width: 3rem;" />
            <span class="badge border border-light rounded-circle bg-success p-2 position-absolute top-100 start-100 translate-middle"><span class="visually-hidden">online</span></span>
          </div>
          <div>
            You<br>
            <small class="fw-light text-muted text-truncate d-block">This is a status</small>
          </div>
        </a>
        
                ...
      
      <div class="col px-0 bg-danger">
        4
      </div>
    </div>
  </div>

</body>

</html>

Please note that the page layout is hidden on small devices, so adjustments may be necessary.

Answer №1

Optimizing your flex classes can simplify your layout. By setting the height of the container and row to h-100 (100%), you can achieve the desired outcome:

html,
body {
    height: 100%;
    overflow: hidden;
}

.sideBar {
    overflow-x: hidden;
    overflow-y: auto;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a5855554e494e485b4a7a0f140a140a">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container-fluid h-100">
    <div class="row h-100 d-none d-md-flex">
        <div class="col px-0 list-group list-group-flush h-100 sideBar">
            <a class="list-group-item text-dark p-3" style="background-color: rgba(0,0,0,.03);">
                <div class="d-inline-block float-start position-relative me-3">
                    <img class="" alt="User" src="https://avatars.githubusercontent.com/u/48397556?v=4" style="max-width: 3rem;" />
                    <span class="badge border border-light rounded-circle bg-success p-2 position-absolute top-100 start-100 translate-middle"><span class="visually-hidden">online</span></span>
                </div>
                <div>
                    You<br>
                    <small class="fw-light text-muted text-truncate d-block">This is a status</small>
                </div>
            </a>

            [other list items with similar structure]

        </div>
        <div class="col-8 px-0 bg-warning">
            3
        </div>
        <div class="col px-0 bg-danger">
            4
        </div>
    </div>
</div>

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

Integrating a feature for displaying No Results Found

I am struggling to modify a script for auto-completing search fields. My goal is to include a "No Results Found" option along with a hyperlink when no matching results are found. I'm having difficulty figuring out how to add an else statement to displ ...

Enhancing Collapsible Bootstrap Cards by Eliminating Borders

On my website, I have a button that reveals a set of cards containing information. These cards are displayed with a small gray border around them, which I'm trying to remove. However, setting border: none; in my CSS doesn't seem to do the trick. ...

Unable to generate dynamic HTML through AJAX request

I made an Ajax API call and received the response in JSON format. I need to create dynamic HTML to display each value in HTML elements. I tried getting the response from the API but couldn't generate the HTML. Can someone assist me with this? Also, I ...

What is the best way to arrange <div> elements with text inside without moving the text?

I need help figuring out how to stack one or more <div> elements on top of another <div> element while maintaining the text content within each. My issue is illustrated in this fiddle: https://jsfiddle.net/rd268ucy/1/. When attempting to drag o ...

What is the process for integrating SAP BO objects into HTML containers?

Has anyone successfully integrated a SAP BO object into an HTML container? I'm looking to embed a dashboard directly onto my webpage instead of redirecting users to a new tab for the Business Objects platform. ...

The signal property 'ɵunwrapWritableSignal' is not found on the specified type 'typeof import/node_modules/@angular/core/index")'

Despite attempting the solutions provided in previous threads, none of them have been successful for me. Can someone please lend a hand with this issue? https://i.stack.imgur.com/sGRsn.png ...

When incorporating Routes into App, it is important to note that React does not accept functions as valid children

I am currently working on wrapping Routes using a Layout component to organize all content within a bootstrap 12 column grid. However, I am facing an issue where my text inside Route components is not being wrapped and I receive a warning stating that func ...

Guide on how to have two controllers execute identical tasks in Angular while modifying the appearance of the website

Trying to recreate Google's homepage functionality using Angular has been challenging for me. Despite watching Egghead videos and studying the API extensively, I couldn't find a specific example for this behavior. Here's what I aim to achiev ...

How you can fix the issue of the "Element not visible" error occurring specifically for one element within the popup

Error Message: "Element Not Visible" when Script Reaches Last Element Despite all attributes being in the same form, an error occurs when the script reaches the last element and displays "element not visible." All elements are enclosed in div tags on the ...

Changing the size of a background image is proving to be quite a challenge for me

I'm completely new to HTML and CSS. I've been working through a book titled The Missing Manual, CSS3 but I've hit a roadblock when it comes to changing the size of an image that I want to use as a background. In order to troubleshoot the iss ...

Tips on customizing the selected icon color in Material-UI's BottomNavigationAction styling

I'm facing an issue with Material-UI styled components and could use some assistance. My goal is to create a BottomNavigation bar in React using Material-UI v5 where the selected option's icon displays in red (#f00) while the unselected icons sho ...

The onclick function in the Navbar div fails to work for inner elements

Within my navbar, there is a .dropbtn div that I want to trigger a dropdown function when clicked. However, only the text "TOTAL" seems to activate this function onclick. The <span> and <i> elements inside the .dropbtn do not respond to clicks ...

Fixed position of the element within a parent stacking context

How can I ensure that the #icon appears below the #dropdown in the following example? https://i.stack.imgur.com/GoBcR.png The position: fixed of #container seems to be creating a new stacking context for its children. Changing the position value fixes th ...

(Background-sizing: Full) encompassing margins

Can anyone assist me with the background-size: cover; issue? I'm facing a problem where the background image I set in the CSS is covering the padding of my image box instead of staying inside the padding. Is there a way to use background: url() and b ...

Pictures fail to load on Safari browser for desktop and iPhone, yet display correctly on various other smartphones and Windows browsers

Having trouble with images not displaying on Safari browsers for Mac and iPhones, but they load fine on Windows and Android. Even after updating to the latest version of Bootstrap, the issue persists. Here are the current Bootstrap content delivery networ ...

Issues with Stylesheet Rendering in Firefox

Take a look at this Kendo UI Dojo example: https://i.sstatic.net/lVfNM.png When rendered in Firefox, the "right" should also be placed in the header, but it's not. It works correctly in IE11 and Chrome. What am I doing wrong? ...

Implementing Pagination Functionality Using Knockout.js

Sample JSON Data [{ "name": "A Goofy Movie (1995) 720p HDTVRip x264 Eng Subs [Dual Audio] [Hindi DD 2.0 - English DD 2.0] Exclusive By -=!Dr.STAR!=-", "progress": 0, "size": "1.06 GB", "downloaded": "87.98 KB", "hash": "8fe65e43464debe ...

Exploring the application of styles within the shadow DOM

I'm experimenting with applying styles to the shadow DOM. Consider the following example: const element = document.getElementById("bar"); const shadowRoot = element.attachShadow({ mode: "open" }); const greeting = document.createElement("p"); gree ...

The vertical alignment feature seems to be malfunctioning in Bootstrap 4

My goal is to center multiple images within their respective divs, but I am facing issues with vertical alignment not working as intended. Even the CSS classes d-flex justify-content-end and text-center are failing to align the icons side by side. I need t ...

Showing data from a JavaScript controller's JSON response in an HTML table

I'm currently developing a spring app using AngularJS and I have a response coming from a JS controller. My goal is to showcase this response in a table on the webpage. The object devDebtTable is accessible to the page from the JS controller. The JS ...