What is the best way to create a scrollable content at the bottom of a column with 100% height?

Criteria:

The main row must have a height of 100%. If the rows overflow the column, the column should become scrollable. Rows should always be added at the end of the column.

Current Issue:

When the row height is set to 100% and overflows the column, scrolling does not work. However, if there is no overflow, rows are added correctly at the end. But when I remove the 100% height, scrolling works but rows are not added at the end.

With 100% Height:

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

Without Height:

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

My code snippet isn't working...

html, body {
  height: 100%;
}
<div class="container h-100">
        <div class="row h-100 align-items-end" style="background-color: red;">
          <div class="col-12" style="overflow-y: auto;">
            <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
            <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
            <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
            <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
            <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
            <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
          </div>
        </div>
      </div>

Answer №1

To achieve a minimum height using the vh unit, you can apply it to the outer row.

.container>.row {
   min-height:100vh;
}

Check this link for more information


Note: For making the bottom aligned div scrollable as suggested in the comments, replace align-items-end with mt-auto and set a max-height on the parent row...

<div class="container">
  <div class="row" style="background-color: red;">
    <div class="col-12 mh-100 mt-auto" style="overflow-y: auto;">
      <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
      <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
      <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
      <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
      <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
      <div class="row" style="height: 80px; background-color: blue; border: 4px solid black;"></div>
    </div>
  </div>
</div>

For additional details, please visit this link

Answer №2

Have you thought about why the red div is set as a parent property of the blue div instead of being a sibling? You can experiment with setting the overflow-y property of .container to scroll by following these steps:

.container {
  overflow-y: scroll;  
 }

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

Using Javascript, create a loop that navigates between two different pages and add a timer on one of them

How can I create a while loop that spans across 2 HTML pages or use a prompt to ask a question? If the wrong answer is provided, I would like to be redirected to another HTML page which will display for 5 seconds before returning to the prompt. This is my ...

Tips on concealing the default browser tooltip in Internet Explorer versions 10 and 11

Whenever I hover on the select box, a default tool-tip appears saying "You must choose an item from the list". I have also installed another plugin for tooltips, but now I am receiving two inline messages - one from my tooltip and the other from the brows ...

How to use Jquery to set the selected item in a dropdown menu

I'm facing an issue with my drop-down menu - whenever I select an option, the page redirects to a different URL. What I want is for the selected item in the drop-down menu to become the new page. Below is the code I have: HTML: <select class="Mob ...

Ways to reduce the size of a Select box when the option text is too lengthy

How can I reduce the size of the select box by splitting the lines of the options I attempted to modify the CSS with: select { width:100px; } However, only the select element was affected. The options remained the same size. My goal is to have ...

Crafting numerous CSS templates

I am currently working on creating multiple boxes or templates (5 on each row) from a movie API. I have successfully retrieved all the necessary data and do not require a responsive design. https://i.sstatic.net/CNz9R.png The issue arises when I attempt ...

Tips for updating the id of a tag using JavaScript?

Html Code:- {% for post in posts %} <article class="media content-section"> <div class="media-body"> <h2><a id="post_title" class="article-title" href="{% url 'post-detail' post.slug %}">{{ post.title }}&l ...

Is it possible to line up two divs perfectly?

Hey there, I'm still trying to get the hang of CSS and using Dreamweaver CS6's fluid grid layout. In my attempt to create a header with two divs inside it - headerleft for an image and headerright for text - I've run into some alignment issu ...

HTML5 Applications with Intel XDK

I'm currently working on an HTML5 application using Intel's XDK platform for building in Android. However, I'm facing an issue where the application crashes when the keyboard pops up upon entering text. Can anyone provide assistance with thi ...

Learn the art of perfectly aligning text in bootstrap 5

I am looking to align text in the same way shown in this image from Libre Office. Libra Office: https://i.sstatic.net/1dvVx.png This is how the webpage appears: https://i.sstatic.net/JnFSP.png Is there a way to make the webpage resemble the formatting i ...

Creating a webpage that utilizes varying headers for each section can help to

When trying to print a multi-page webpage, I encounter an issue with the headers. How can I ensure that different headers appear on each page after the first one? Specifically, my problem arises when a label on the first page spans across to the second pa ...

Determine discounted prices using AngularJS

My dilemma involves a straightforward form where I input the product cost, markup percentage, and final sale price. Unfortunately, angularjs is not providing me with the correct value based on my inputs. Let's break it down: Let's say I have a ...

Ensuring the persistence of div contents

I am facing a unique challenge and could use some assistance. Below are two segments of HTML: <div id="main_"> <ul class="unstyled"> <ui:repeat var="adultPassenger" varStatus="adult" value="#{bean.adultPassengers}"> <li&g ...

Sort PHP results by the initial letter of the name in a stylish manner

Hello, I am attempting to organize categories by the first letter and format them using ul and li elements. Here is my code: $Sql = "SELECT *, COUNT(Cup_Id) AS num FROM tabcup INNER JOIN tabcats ON tabcupom.Cat_Id = tabcats.Cat_Id ...

Leverage Bootstrap for your Vapor project

I'm just starting out in web development and have been struggling to find a definitive answer. Can Bootstrap be used in Vapor with Swift 3? ...

Mobile responsiveness issue with basic bootstrap navigation bar not collapsing

After trying everything possible, I am still unable to resolve my issue and it is leaving me puzzled. MY ISSUE Simplifying my page, I used the example from w3schools for a responsive navbar. When resizing the browser window, the navbar collapses correctl ...

Exploring the magic of Hover effects using CSS and JQuery

I am exploring ways to enhance the display of an element when hovering over it. I have implemented a button and my objective is for the first click to activate the hover effect, while the second click will reset it. However, I am facing an issue where the ...

Conceal the input field in a Vue.js datepicker

In my Vue project, I am utilizing the vuejs-datepicker component. My goal is to hide the default input field and display the Calendar only when the user clicks a button. To achieve this, I have placed the <datepicker/> within a div and applied CSS to ...

Aligning the menu links to the right on a horizontal CSS menu

I have created a horizontal menu using CSS and HTML with the following code: .nav > li:hover { background: #666666; text-decoration:none; } .active { background: #666666; text-decoration:none; } nav, ul, li, a { margin: 0; paddi ...

Modify the date format inside the content of an HTML element or its descendants (excluding their attributes)

I have been trying to reformat some dates using JavaScript. My initial approach was: var regex = /(\d{4})-(\d{2})-(\d{2})/g; $('.container td').each(function() { $(this).html($(this).html().replace(regex, '$3-$2-$1')); ...

Expand to the right: Bootstrap 4 modal popup header shifts right upon clicking

When I click the login pop up on my bootstrap 4 header, it stretches all the way to the right. View my header See how the header looks when the login pop up is clicked This is the link code I am using: <li class="nav-item"> <a class="nav-l ...