Is there a solution for addressing this overflow issue without specifying a height parameter?

After spending several days working on this interface with bootstrap4, I am struggling to implement a scrollbar in one of the divs without setting a fixed height in pixels. Can anyone provide guidance on managing a one-page design effectively?

For reference, here is the link to the HTML code:

Answer №1

To enable scrolling for an element within a flexbox, you can create a new container inside the flexbox element and set it to position: absolute;

Feel free to refer to my example below.

#chat-list {
position: relative;
    overflow-y: scroll;
    height: 100%;
}

.chat-scroll {
  position: absolute;
  top: 0;
  left: 0;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8>
  <title>Document</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
  <div class="container border bg-success w-100" style="height: 95vh;">
    <div class="row h-100">
      <div class="col-md-12">
        <h3>My Whatsapp</h3>
      </div>
      <div class="col-12 col-sm-5 col-md-4 d-flex flex-column border " id="chat-list-area" style="position:relative; ">
        <!-- Navbar -->
        <div class="row d-flex flex-row align-items-center p-2 bg-warning " id="navbar">
          <div class="text-white font-weight-bold">My Chats</div>
          <div class="nav-item dropdown ml-auto">
            <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-ellipsis-v text-white"></i></a>
            <div class="dropdown-menu dropdown-menu-right">
              <a class="dropdown-item" href="#">New Group</a>
              <a class="dropdown-item" href="#">Archived</a>
              <a class="dropdown-item" href="#">Starred</a>
              <a class="dropdown-item" href="#">Settings</a>
              <a class="dropdown-item" href="#">Log Out</a>
            </div>
          </div>
        </div>
        <!-- Chat List -->
        <div class="row" id="chat-list">
          <!-- new container -->
          <div class="chat-scroll">
            <!-- new container -->
            <div class="col-xs-12 w-100 bg-light">
              
              <!-- Many more chat items here (omitted for brevity) -->
              
            </div>
          </div>
        </div>
        <!-- Profile Settings -->
      </div>
      <!-- Message Area -->
      <div class="d-none d-sm-flex flex-column col-12 col-sm-7 col-md-8 p-0 " style="height: 95%;" id="message-area">
        <!-- Navbar -->
        
        <!-- More content follows here (omitted for brevity) -->
        
      </div>
    </div>
  </div>
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>

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

Creating dynamic canvas elements with images using HTML and JavaScript

Currently, I am working on a unique project involving a canvas filled with dynamic moving balls. This project is an extension or inspired by the codepen project located at: https://codepen.io/zetyler/pen/LergVR. The basic concept of this project remains t ...

Any tips or hacks for successfully implementing vw resizing on the :before pseudo-element in webkit browsers?

When using vw sizes on webkit browsers, a well-known bug can occur where they do not update when the window is resized. The typical workaround for this issue has been to employ javascript to force a redraw of the element by reassigning the z-index upon res ...

Tips for designing adjustable text in bootstrap 4

Could someone please assist me with making text responsive using Bootstrap 4? I have searched everywhere but it's strange to see that there are no tutorials on this topic. Below are my codes in case you would like to provide guidance. <div class=" ...

The span's presence causes the neighboring span to shift downwards

HTML <span class="symbol">$</span> <span class="value">400</span> This code snippet displays the symbols "$" and "400" at the same level in the document. However, if we introduce some styling using CSS: .symbol { font-size: 2e ...

Identification of absence of file selected in input file control

Imagine a scenario where I need to select an image to display on the screen from a select control. If the desired image is not available, I want to be able to choose it from the disk and add this option to the select control while automatically selecting i ...

PayPal form without encryption

Once upon a time, I recall creating a button in Paypal which provided me with a standard HTML form. However, now everything seems to be encrypted. Is there a way to retrieve an unencrypted format? I need to be able to manually adjust the price using jQuer ...

Can someone please provide guidance on how to focus on these boxes? (see image below)

My goal is to specifically target the boxes with white dots inside them. Each black box in this picture represents a blog post, even including the larger one at the top. I initially considered using the nth-child selector, but I'm not confident in how ...

Prevent any sliding animations of content when the button is triggered

I've implemented a basic slideToggle functionality in jQuery. You can check out the code on JSFiddle here: $(document).ready(function() { $(".panel_button").on('click', function() { $(".panel").slideUp(); var targetPanel = $(thi ...

I am encountering an issue while developing a JavaScript filtering system

Hey everyone, I need help with coding a filter in JavaScript and I'm running into an error (Uncaught TypeError: todos.forEach is not a function) that I can't figure out. Can someone assist me in resolving this issue? const todoFilter = docume ...

The unique and personalized accordion panel is experiencing technical difficulties

Here is the accordion script I am using: $(document).ready(function(){ $(function(){ // Accordion Panels $(".accordion span").hide(); $(".accordion li").click(function(){ $(this).next(".pane").slideToggle("fast").siblings(".pane:visible").sl ...

Is there a way to retrieve all "a" tags with an "href" attribute that contains the term "youtube"?

My goal is to capture all a tags that have the href attribute containing the word youtube. This task requires the use of jquery. ...

Text breaks down as it stretches past a certain length

Implementing a manual line break resolves the issue, however, without it, everything becomes jumbled together. Here is the CSS code being used: header { background: #fcb9aa; color: #f3d9d9; height:100px; margin: 0; padding: 0; posi ...

What is the interaction between CSS and URL fragments (the #stuff)?

Can URL fragments affect CSS behavior? For instance, let's consider a sample page at: http://example.boom/is_this_a_bug.html. You can view the code for this page on https://gist.github.com/3777018 Upon loading the page with the given URL, the element ...

Is there a way to verify the selection of all mandatory fields prior to concealing a div?

var count = 2; $('.next').click(function() { var requiredField = true; $(this).siblings('table').find('tbody tr:nth-child(' + count + ') td').each(function() { var element = $(this).find('center').f ...

The text cursor keeps bouncing back and forth between mat-input fields as I try to input values

In my Angular 9 application, I am dealing with a dynamic list of numbers that can change during runtime. These numbers need to be bound to matInput fields so that each input field corresponds to a number in the list. This is how I have implemented it: TS ...

Activate scroll function exclusively upon hovering over specific object

I am working on a page with an object that allows users to zoom in and out. I want to create a special zoom function that will be triggered when the user scrolls while their cursor is hovering over this object. If the cursor moves away from the object, th ...

Why is my browser failing to show spaces in list text when using the SELECT tag?

While using IE7, I noticed that the options in my SELECT tag are displayed without the leading spaces in the text - it appears that the text is being trimmed. For instance, in the HTML code block provided below, even though options 1 to 3 have three spaces ...

The functionality of the Bootstrap 5 dropdown button remains elusive, despite including all required scripts within the index.html file

I'm currently working on incorporating a dropdown button into my React project. Utilizing Bootstrap 5, I have already included the necessary jQuery and Bootstrap scripts. Below is the code snippet I've developed to create a dropdown button: < ...

What is the best way to crop a page?

Running a React application, I am integrating a page from an external ASP.NET app. To achieve my goal of extracting only a section of the page rather than the entire content, I am unsure if it is feasible. Specifically, I aim to extract just the body of th ...

Dynamic sliding effect in CSS for seamless showing and hiding of div elements

I stumbled upon a fantastic solution in these forums How to create sliding DIV on click? However, what I really wanted was for the content to fade in and out with just a click of a button. Here is the code snippet I am currently working with: <html> ...