What steps can I take to ensure that the content within my bootstrap container always fits neatly within the container boundaries?

I'm attempting to structure one container with 3 rows. The first row contains the header, the last row the footer. In the middle row, I want two columns. The left column should display multiple scrollable cards. I've tried various methods to make the elements fit the 100vh of the container without success. Essentially, I need a scrollbar only in the left column of row 2. Everything should be properly displayed on the screen.

For reference, here is the link to my code: https://codepen.io/PrestigeEis/pen/ExbqWpR

<div class="container-fluid vh-100">
      <div class="row" id="row1">
        <div class="col-3 border titleCol">DEM Units consumption</div>
        <div class="col-9 border titleCol">Detail Page</div>
      </div>
      <div class="row" id="row2">
        <div id="customerList" class="col-3">
          <div class="card customerCard">CustomerA</div>
          <div class="card customerCard">CustomerB</div>
          <div class="card customerCard">CustomerC</div>
          <div class="card customerCard">CustomerD</div>
          <div class="card customerCard">CustomerE</div>
          <div class="card customerCard">CustomerF</div>
          <div class="card customerCard">CustomerG</div>
          <div class="card customerCard">CustomerH</div>
        </div>
        <div id="detailPage" class="col-9"></div>
      </div>
      <div class="row" id="row3">
        <div class="col-3 border footerCol"></div>
        <div class="col-9 border gap-2 footerCol">
          <button type="button" id="safeBtn" class="btn btn-primary">
            Save
          </button>
          <button type="button" id="cancelBtn" class="btn btn-outline-primary">
            Cancel
          </button>
        </div>
      </div>
    </div>

CSS Style:

html,body, #root {
  margin: 0;
  height: 100%;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #f7f7f7;
}


::-webkit-scrollbar-thumb {
  background: #9b9a9a;
}


::-webkit-scrollbar-thumb:hover {
  background: #8c8c8c;
}

#customerList {
  background-color: #f7f7f7;
  overflow-y: scroll;
  padding: 0px;
  max-height: inherit;
}



#detailPage {
  background-color: #f7f7f7;
  padding: 0px;
}

.customerCard {
  min-height: 150px;
  border-radius: 0%;
}

.titleCol {
  background-color: #ffffff;
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.footerCol {
  background-color: #ffffff;
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: end;
}

#safeBtn {
  background-color: #0a6cd1;
}
#safeBtn:hover {
  background-color: #085caf;
}

#cancelBtn {
  color: #085caf;
  border-color: white;
}

#cancelBtn:hover {
  color: #085caf;
  border-color: #085caf;
  background-color: #ebf5fe;
}

#row1{
  max-height: 10vh;
}

#row2{
  max-height: 88.2vh;
}

#row3{
  max-height: 10vh;
}

Answer №1

If you want to structure your webpage effectively, consider placing your header within <header> tags, organizing your content within one or more container elements, and positioning the footer within <footer> tags.

<header>
   Logo and menu etc
</header>

<div class="container">
   Main page content
</container>

<footer>
   Foot-menu copyright blurb etc.
</footer>

You can create two columns within the container by including a row.

<div class="container">
  <div class="row">

    <div class="col-sm-12 col-md-6">
      <!-- full width on small screens and left column on mediums screens and above -->
    </div>

    <div class="col-sm-12 col-md-6">
      <!-- full width on small screens and right column on mediums screens and above -->
    </div>

  </div>
</div>

To enable a scroll bar in one of the columns, simply manage the overflow property.

HTML

 <div class="col-sm-12 col-md-6 card-column">

CSS

.card-column{
overflow: 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

Transform the CSS to a Mat-Form-Field containing a search box within it

I am currently working with Angular, Angular Material, and SCSS for my project. Here is the front-end code snippet that I am using: <mat-form-field class="custom-form-field" style="padding-top: 5px;padding-bottom: 0px; line-height: 0px; ...

What is the best way to insert a character (::before) before an element?

I am trying to add a circle/dot using ::before on an element. • • However, I cannot seem to make it visible! .line ::before{ content:'•'; } and .line ::before{ content:'•'; } (Still not showing) I ...

Using jQuery, set a restriction on the total number of options in three dropdown menus to

I am currently facing a challenge with 3 dropdowns, each containing 8 options. My aim is to restrict the total selection across all three dropdowns to 8. For instance, if I choose 7 in the first dropdown, I should only be able to pick 1 in the next two. Si ...

How to make an image expand to fit the screen when clicked using HTML and CSS

Is there a way to make the images on this page grow to screen size when clicked, rather than extending past the boundaries of the screen? Currently, the images enlarge to twice their original size on click. How can I ensure that they expand responsively to ...

Enhance your website with footer animations using jQuery!

I am implementing a sticky footer on my website to keep the footer at the bottom using CSS. I want the footer to initially be collapsed and expand when the user clicks on a button, swapping the "expand" link with a different container div inside the footer ...

Is it possible to choose a complete HTML element within NetBeans?

Currently using netbeans 7.1 and curious about the possibility of selecting an entire HTML element such as a div tag. If I wanted to select the inner div for deletion: <div id="outer"> <div id="inner"> This is inner Content </ ...

Enhancing the performance of jquery selection speed

I am currently working on a code that manipulates the HTML code of an asp.net treeview. Since this code runs frequently, I need to ensure that it executes with maximum speed. I am interested in expanding my knowledge on jQuery selectors and optimizing th ...

What is the best way to create a triangle shape that is responsive to elements?

I'm trying to make a background shape with a triangle inclusion using CSS. I want it to be responsive to all screen sizes, but I'm having some trouble. Any tips on how to achieve this? header { width: 100%; height:150px; background: #eee; } m ...

Guide on using Python to save a legitimate HTML page of a YouTube video

When I use requests.get(URL, allow_redirects=True) on websites like Youtube or Reddit, instead of seeing the usual HTML text content that appears when I view the page in a browser, I get a bunch of unexecuted JavaScript. All I really need is the title of ...

A method for positioning each pair of <li> elements side by side

My goal is to arrange every pair of li elements next to each other (e.g. 0-9, A-B, C-D, ...). Currently, they are aligned one by one. <ul> <li class="alphabetRow"><a href="#" id="alpha_1" class="alphabet active" >0-9</a></li ...

Arranging pictures in both vertical and horizontal alignment (CSS)

I've been attempting various methods to solve this issue, but none have proven successful. My goal is quite simple: align images both horizontally and vertically in a manner that fills empty spaces with photos. Similar to the layout here: The challe ...

Accessing a variable from an external JavaScript file using jQuery

Can someone help me out with this issue I'm facing? I am having trouble getting a string returned to a variable in my embedded Javascript code. token.js: function token () { return "mysecretstring"; } HTML Code: <!DOCTYPE html> <h ...

Steps for serving audio files in a Spring Boot application

Can someone advise on the best location to place my audio folder in order to reference it as src="audio/audio_name" within an HTML audio tag? I attempted placing it in the resources folder, but when using src="http://localhost:9191/resource ...

Ruby on Rails allows for the selection of values in a dropdown menu to trigger the visibility of different sections of HTML

As a newcomer to Rails, I was able to successfully implement the onclick function for a f.checkbox element. Now, my challenge lies in achieving a similar functionality for a f.select element within a _form. Below is the code snippet that works for a chec ...

minimize javascript syntax (stackoverflow 2022)

I'm struggling with this puzzle game. Sometimes, when I start a new game, the pieces get shuffled incorrectly. I tried adding a function to fix it, but it doesn't seem to be working. It's really frustrating and I want to simplify the code as ...

Reading settings from web.config file in an HTML page

Currently working with ASP.NET 3.5 web forms. I've recently saved the path of my website in the web.config file under the key "CommonPath". I have a basic static HTML page that I would like to utilize this key on. Any suggestions on how to achieve ...

The search functionality in an Html table is currently malfunctioning

Currently, I am working on developing a search mechanism in HTML. It seems to be functioning properly when searching for data for the first time. However, subsequent searches do not yield the expected results. Additionally, when trying to search with empty ...

Fade background position rollover effect

I'm facing a challenge with animating my background image using background positioning. The CSS is functioning correctly, but when I attempted to enhance it by adding jQuery for a rollover effect, the animation isn't working as expected. Can anyo ...

Issue encountered when toggling flip switch in Jquery Mobile

I am trying to create a calculator for my app using Jquery Mobile, but I am facing an issue with the flip toggle switch. Here is my script: <script type="text/javascript"> function dosis() { $peso = $('#peso').get(0).value $dosis = ...

Can you explain the significance of xs, md, and lg within the CSS Flexbox framework?

Currently in the process of developing an application using React and looking to apply some styles to my components. I stumbled upon which delves into a fluid grid system. A snippet from the example is shown below: <Row> <Col xs={12} sm={3} m ...