Utilizing Bootstrap 4.5 for a seamless user experience, implementing separate scrollbars for improved navigation, and ensuring

I'm currently working on a layout that involves organizing elements into 3 columns using Bootstrap 4.5.

The center column will contain a lengthy body of text.

Within the right column, there are two divs, one of which should be fixed either to the top or bottom. However, I am facing challenges getting the bottom element to remain fixed as desired due to auto-expansion. It's particularly tricky when it needs to expand from the bottom.

At the top of this right column, I am utilizing Tocify for my Table of Contents (ToC).

In the left column, there are several divs. The first div is a banner that I want to stay fixed at the top. The other divs are less crucial. In cases where the viewport size causes overflow in this column, I require an independent scrollbar specifically for the left column. Ultimately, I aim to have two separate and independent scrollbars - one for the webpage and another for the left panel.

To see an example with a long body showcasing the issue, you can check out this loaded fiddle using Bootstrap here: https://jsfiddle.net/x1nhrwtf/5/

<body>
  <div class="container-fluid">
    <main class="container py-3">
      <div class="row">

        <aside class="col-md-2">

          <div class="row banner sticky-top bg-white p-3">
            This will serve as a banner that remains fixed at the top.
          </div>
          <div class="scrollable-area hide-this-on-small-devices">
            <div class="row bg-white p-3">
              This column should not scroll alongside the middle section unless its contents overflow, in which case, I need a distinct scrollbar.
              <hr />
            </div>
            <div class="row bg-white p-3">
              This area will house a search bar. Hidden on small devices.
            </div>
            <div class="row bg-white p-3">
              These divs will display announcements. Hidden on small devices.
            </div>
            <div class="row bg-white p-3">
              Here we showcase BuiltWith information. Also hidden on small devices.
            </div>
          </div>
        </aside>

        <section class="content col-md-6">
          Lorem ipsum dolor sit amet...
        </section>

        <aside class="col-md-4">
          <div class="toc sticky-top bg-white p-3">
            <h3>Table of Contents Section, sticky</h3>
            <hr />
            This section should remain positioned correctly. Even on small devices, it must stay at the top. The height of this element expands automatically to 60%.

            A Tocify-style Table of Contents:

            <div id="toc" class="pl-1"></div>
          </div>

          <div class="comments sticky-bottom bg-white p-3">
            <h3>Comment Section</h3>
            <hr />
            This portion should stick to the bottom of the column and page. Its height also expands automatically but to 40%.
          </div>

        </aside>
      </div>
    </main>
    <footer class="footer">Here is a footer. It should always be stuck along the bottom. Why does it seem missing?</footer>

  </div>
</body>

CSS Attempt:

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}

.toc {
  max-height: 60%;
}

.comments {
  max-height: 40%;
}

.scrollable-area {
  overflow-y: auto;
}

Answer ā„–1

In solving this problem, I designed a layout with three columns within a container. The container has overflow: hidden and height set to 100vh to prevent page scrolling. Each column has overflow scroll to enable parallel scrolling.

Additionally, I have addressed all your requirements. The top components in the left and right columns are marked gray and remain fixed at the top of the screen. Comments stay at the bottom of each column, and the footer is displayed at the very bottom.

html,
body {
  margin: 0;
  padding: 0;
}

.container {
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  width: 100vw;
  height: 100vh;
  border: solid 1px red;
  overflow: hidden;
}

.col {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: auto;
  overflow: auto;
  padding: 3px;
}

.col-md-2 {
  width: 16.6666666667%;
}

.col-md-4 {
  width: 33.3333333334%;
}

.col-md-6 {
  width: 50%;
}

.center {
  background-color: green;
  text-align: justify;
}

.sticky-top {
  position: fixed;
  width: inherit;
  top: 0;
  background-color: gray;
}

.sticky-bottom {
  position: sticky;
  bottom: 0;
}

.scrollable-area {
  position: relative;
  z-index: -1;
}

.toc {
  height: 60%;
  max-height: 60%;
}

.comments {
  position: fixed;
  bottom: 0;
  z-index: -1;
  height: 40%;
  max-height: 40%;
}

footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 100;
  background-color: black;
  color: white;
}
<div class="container">
  <div class="col left col-md-2">
    <div class="banner sticky-top">
      This will be some banner. Should always stick to the top.
    </div>
    <div class="scrollable-area hide-this-on-small-devices">
      <div class="row bg-white p-3">
        This column is <em>not</em> supposed to scroll along with the middle section, <em>unless</em> the elements are overflown (in which case, I want a separate scrollbar).
        <hr />
      </div>
      <div class="row bg-white p-3">
        This will have a search bar. Hide this on small devices.
        <hr />
      </div>
      <div class="row bg-white p-3">
        This will have announcements. Hide this on small devices.
        <hr />
      </div>
      <div class="row bg-white p-3">
        This will have BuiltWith. Hide this on small devices.
        <hr />
      </div>
    </div>
  </div>
  <div class="col center col-md-6">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Volutpat sed cras ornare arcu dui vivamus arcu...
    
    ...lobortis elementum nibh tellus molestie nunc non. Nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Gravida arcu ac tortor dignissim convallis aenean et. Tincidunt tortor aliquam nulla facilisi cras fermentum odio. Vel pretium lectus quam id leo in vitae turpis. Ullamcorper velit sed ullamcorper morbi tincidunt ornare. Sit amet commodo nulla facilisi nullam. Senectus et netus et malesuada. Id porta nibh venenatis cras sed felis
    eget.<br> Ultrices sagittis orci a scelerisque. Faucibus et molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Id velit ut tortor pretium viverra suspendisse potenti nullam. Purus gravida quis blandit turpis cursus. Non curabitur gravida
    arcu ac tortor dignissim. Porta nibh venenatis cras sed. Gravida dictum fusce ut placerat orci nulla. Justo laoreet sit amet cursus sit amet dictum. Non diam phasellus vestibulum lorem sed risus. Non enim praesent elementum facilisis leo vel fringilla
    est ullamcorper.<br> Mattis aliquam faucibus purus in massa tempor nec feugiat nisl. Porta non pulvinar neque laoreet suspendisse interdum. Leo urna molestie at elementum. Aliquet porttitor lacus luctus accumsan. Arcu non sodales neque sodales ut.
    Vitae turpis massa sed elementum tempus egestas. Faucibus in ornare quam viverra orci sagittis. Sociis natoque penatibus et magnis dis parturient. Lacus suspendisse faucibus interdum posuere. Odio facilisis mauris sit amet massa vitae tortor condimentum
    lacinia.
  </div>
  <div class="col right col-md-4">
    <div class="toc sticky-top bg-white p-3">
      <h3>ToC Section, sticky</h3>
      <hr /> This is positioned correct, pretty much. Should stay at the top, even on small devices. This element auto-expands to 60% height.
    </div>
    <div class="comments sticky-bottom bg-white p-3">
      <h3>Comment section</h3>
      <hr /> This should stick to the bottom of the column (and page). This element auto-expands to 40% height.
    </div>
  </div>
</div>
<footer class="footer">Here is a footer. It should be stuck across the bottom. Why is it not there?</footer>

Answer ā„–2

The footer is still present at the bottom, perhaps it went unnoticed due to the console of jsfiddle covering it.

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

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

Customize the CSS style of a component in VueJS

After creating styles for my website, I encountered a challenge. Users input specific content using a WYSIWYG editor, and I want this content to have a distinct style without affecting the rest of the site. Despite trying various methods like , I couldn& ...

WordPress footer widgets appearing misaligned

I have made a child theme for Twenty Thirteen and am in the process of making some updates to it. My development site is essentially a replica of the live site. The only modification I made in the footer section was to change the widget title styles, but I ...

Getting a box-shadow programmatically in Opera can be achieved by using the appropriate CSS

Trying to achieve the same effect with jQuery: item.css("-o-box-shadow") or: item.css("box-shadow") However, the result is an empty string. In Webkit and Gecko browsers it works by using "-webkit" and "-moz" prefixes respectively. How can this be ach ...

Pause for a minimum of 2 seconds after ajax has been completed before proceeding with transition.next() using Vue.js

For the smooth transition after completing an ajax call, I need to display the spinner for a minimum of 2 seconds. Below is my code, which unfortunately isn't functioning as expected: route: { data(transition) { this.getDelayedData(); ...

Show a flash message and error notification following an AJAX call in Laravel

When making an ajax request successfully, I need to display a flash message in my view. For instance, after editing something, I want the user to be redirected to the homepage with a message like "$flash = Your changes have been saved". It's simple to ...

Tips for quickly referencing the HTML select tag

I have a dropdown menu in my HTML that is linked to my database's location table. When a user selects an item from this dropdown, I want the second dropdown (linked to the product table) to dynamically update based on the user's selection from th ...

What is the reason behind Bootstrap 4 opting for the A3 page size as its default?

By default, the $print-page-size variable is set as A3. Isn't this size much larger than what most people can print? In the UK, printing on A4 (half that size) is considered normal. ...

What's going on with the background color? It doesn't seem

I have incorporated Bootstrap into my html code and I am attempting to modify the background color of a div when the screen resolution changes from large to medium or small. Even though I have added a class, the change does not reflect when adjusting the ...

Clicking on text will open a popup div using HTML and CSS

I am looking to create a popup div instead of a popup window for my 'About' picture/page with the current button. Here is an example: ...

The Ajax code fails to refresh the document object model

I've encountered a small issue with my Ajax script that performs a POST request and displays the result on the screen. Even though the POST request is successful, I'm not able to view the result on the screen. It seems like there might be a need ...

How can I maintain my bottom navigation bar in Bootstrap 3 without using a 3 span icon?

Hey everyone, I'm still getting the hang of MVC as I only started using it around 3 weeks ago. Currently, I am working on a Web Application where I am trying to implement a specific feature: At the bottom of the page, I have a navbar with some Html. ...

When trying to display an image using CSS, the image does not appear on the screen

I've been working on streamlining my HTML code and moving as much as possible to my CSS file. However, I'm facing an issue with getting an image to display when writing the CSS code for it. Here's the HTML: <html> <head> <l ...

Ajax sending incorrect parameter values

Having some trouble with an ajax request where the parameter I am trying to send is not being transmitted correctly. The issue seems to be in my user.php file. <script> function showUser(str) { if (str=="") { document.getElementById("txtHint" ...

Click-o-Meter: Tracking Button Presses

Iā€™m looking to develop a button click counter that increases every time it is downloaded. I want to implement this functionality without using a database. Here's the code snippet: <?php $counterFile = 'path/to/counter.txt' ; ...

Utilizing jQuery or PHP to Extract Page Details

I'm in need of guidance for developing a script that I have in mind. My goal is to create a script that operates similarly to Facebook, allowing users to input a URL and retrieve the 'page information' from that URL. In addition, if a user ...

Finding the label that is linked to the current DIV or textarea by its "for" property

I am working on a project that involves two elements - a textarea and a div. Each element has a label attached to it using the "for" attribute in HTML. <textarea id="txta_1" class="txta" cols="40" rows="3" onkeyup ...

Creating a border with tabs and a triangle using CSS

I'm having trouble getting my HTML/CSS tabs to look like the ones in the image. I've experimented with border-radius but haven't been able to achieve the desired result. Can anyone provide guidance on how to replicate these tabs using only ...

Vue's watch feature will not execute if the watched property remains unchanged during a page reload

<template> <!-- The navbar has a property for gender, the color of the navbar will change depending on the gender --> <!-- pass the props gender through a form submission and event --> <div class="nav-main" :class="{f ...

Executing Ajax requests with callbacks in JavaScript/jQuery

I'm facing an issue where my functions are executing before Ajax requests (first fetching local JSON, then retrieving data from an online resource) have completed. For example, I want countTheMovies to run only after all the necessary information is ...

Holding off on executing a JQuery function until after another JQuery function has completed its task

I have a complex series of functions set up to populate the DOM with movie information. Initially, I make a call to a custom JSON file containing a list of movies, which then triggers calls to the OMDb API for each movie to retrieve specific details. The g ...