Bootstrap Sidebar with Full-Height Footer

Seeking a solution for creating a full height sidebar (#left) along with footer using the bootstrap framework.

Check out the fiddle linked here.

I have experimented with the code below, but it doesn't work well with the footer. The objective is to make the sidebar cover 100% of the page height.

#left {
    position: fixed;
    top: 51px;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: block;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #f5f5f5;
    border-right: 1px solid #eee;
}

Answer №1

To make the row display flex for viewport width greater than 992px, you can add the following CSS:

@media (min-width: 992px) {
  .row {
      display: flex;
  }
}

Check out the FIDDLE here!

NOTE: Be cautious as this change may impact other parts of the layout. To avoid this, adjust the selector to specifically target only the desired row.

Answer №2

There's a different perspective I'd like to share. Bootstrap offers classes for setting up rows and columns.

<div class="row">
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
  <div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
  <div class="col-md-6">.col-md-6</div>
  <div class="col-md-6">.col-md-6</div>
</div>

Discovering the appropriate class numbers can make your website responsive. Thank you.

Answer №3

Give this a shot

body {
      overflow: hidden;
}    

#left {
      background-color: #aaa;
      padding-bottom: 99999px;
      margin-bottom: -99999px;
}

.footer {
    position: relative;
    z-index: 99;
    background: #fff;
}

Try enclosing it in a wrapper (e.g.

<div class="wrapper"></div>
) and apply CSS to that wrapper (.wrapper { overflow: hidden; }). Another option is to use a different class/id with the style attribute overflow:hidden.

Answer №4

Your solution is quite simple and the code you have used is absolutely fine.

Update:

#left {
    position: absolute; //changed from fixed
    top: 51px;
    left: 0; // removed bottom:0;
    z-index: 1000;
    display: block;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: pink;
    border-right: 1px solid #eee;
}

A couple of small adjustments to other elements will help achieve the desired outcome here. Assuming that when you mentioned 100%, it does not include the top navbar.

1) Shift the id="main" div to the right using float: right; so it aligns with the layout and does not get covered by the #left sidebar. Like this:

#mid {
  float: right; //added
  background: #666;
}

2) Regarding your footer issue, the problem lies in the positioning of the <footer> section. If you want the sidebar to extend to full height even below the footer, place it inside the #main div after the content.

Check out the latest fiddle.

Answer №5

While CSS can accomplish the task, there are limitations to that approach. Additionally, browser compatibility issues still exist with Flexbox.

An alternative solution using jQuery is available. Just a few lines of code can achieve the desired outcome.

To begin, create a function:

function adjustSidebarHeight() {
  var containerHeight = $('.main-content').height();
  $('.sidebar').height(containerHeight);
}

Next, execute this function on page load and when the browser is resized.

$(window).on('load resize', adjustSidebarHeight);

For more detailed information, I have written a tutorial on my Website. You can also view a demo on Codepen.io.

Answer №6

Consider using position: absolute in place of position: fixed.

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

Ensuring consistent column widths in tables using Bootstrap 5 and Angular

In my angular application using Bootstrap 5, I have a table structured like this <table> <thead> <tr> <th [ngClass]="{'d-none':prop1==0}"></th> <th [ngClass]="{'d-none':prop2==0} ...

The context of the selector causes an error to be thrown

Why does jQuery throw an exception when I attempt to select an element with context? The code is as follows: jQuery('b', "DAS<br/><br/><b>ID</b> = 02<br/><b>NAMA DAS</b> = CITARUM<br/><b>LUAS ...

Crop images in a canvas using a customized rectangle with the help of JQuery

I am trying to crop an image inside a Canvas element using a selection rectangle. My project utilizes jQuery and I am in search of a plugin that can help me implement this custom selection rectangle on the canvas itself, not just on images. Are there any ...

JavaScript consistently returns HiddenField as NULL

After creating a Context menu and associating it with a Gridview, I noticed a problem when pressing a button from the context menu. I intended to retrieve a value from a HiddenField, but it always returns null. My assumption is that the DOM might not be fu ...

Position the checkbox to the left of the label

I currently have a checkbox with ripple effects. The label text is displayed before the checkbox in the code. However, I'd like to change the order so that the checkbox comes before the label text. Occasionally, the entire div expands and contracts. ...

Trouble with find_element_by_xpath in Python's headless mode

When using selenium with python, the code snippet below functions correctly in non headless mode. However, upon switching to headless mode, an error is encountered: raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElement ...

Encountering an error message "Module 'jquery' not found" while utilizing browserify

I'm currently experimenting with browserify for a small web project. My goal is simple: I want to be able to use require('jquery') in my JavaScript instead of including the dependency with a <script> tag in the HTML. Here's what ...

When the react autocomplete dropdown appears, it pushes other input elements downward, affecting their

Having implemented an autocomplete dropdown feature by following this link, I am encountering an issue with displaying the dropdown items. As shown in the reference link, the dropdown items are rendered within a div tag with the position set to relative. ...

Implementing conditional statements using jQuery for multiple selections

Having two unique IDs, I am planning to set a condition that corresponds with my query. $("#foo", "#bar").foo.bar({ baz: function() { if(selector == "#foo") { console.log("foo"); } else { console.log("bar"); } } }); ...

AngularJS allows for the creation of a disabled select tag that can selectively choose options from another select tag using ng-repeat

Is there a way to disable one select element by choosing a specific option from another select element? Below is the HTML code: <select name="" ng-model="round.evaluation.availability" required ng-change="update()"> <option value="">Selec ...

Understanding ng-if in AngularJSAngularJS includes a useful directive called ng

After using angularJS, I found myself wondering how to effectively implement its if statement in a particular way. I hope that my example will help clarify my question. Here is the if statement I am working with: <div data-ng-if="book.Availability> ...

How can the entire menu be closed in Bootstrap 5 when clicking on a link or outside of the page?

I'm currently utilizing BootStrap 5 for constructing my webpage. Within my page, I have a NavBar Menu containing various links. <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__ ...

Having trouble updating the value in the toolbar?

Here is an example that I added below: When I click the add button, the value of the "newarray" variable is updated but not reflected. I am unsure how to resolve this issue. This function is used to add new objects: export class AppComponent { ne ...

`Flex alignment of columns in Bootstrap 4`

I'm feeling really lost here. I had everything figured out, but after refreshing the jsfiddle, the solution suddenly changed on me. I have a row with two columns in it, but for some reason, I can't get them to align properly on the same row. I at ...

Arranging column contents neatly on small screens

Although there are similar answers available, I want to address those who are trying to prevent their columns from stacking on XS display. Despite having two columns, the content is still stacking at certain displays. This issue is occurring while using B ...

Mapping the selection from jquery-ui's autocomplete to a Java class during a POST request

Let's consider a scenario where we have a customized Java class named Club.java: public class Club { private Integer id; private String name; /* getters, setters */ } Next, let's take a look at the jquery-ui autocomplete code: v ...

Resize drop zone with drag and drop functionality

I am using jQuery for dragging and dropping elements, but I am facing an issue. When I resize the drop zone while starting to drag an item, it seems like the previous size of the drop zone is still being used as the space. Is there a way to fix this? ...

Concealing tables or forms using Javascript

I need a function to toggle the visibility of an HTML element when clicking on another element. The menu I have includes a submenu with two options - one to display a table and the other a form. Clicking on the first option reveals the table, and then cli ...

Transmit information via AJAX to the @RequestBody annotation in a Spring application

When working with Spring Java, I used response entity and request body to insert data but encountered an error - 404 not found. This is my controller: @RequestMapping(value = "insertuserlogin/", method = RequestMethod.POST) public ResponseEntity<?> ...

Is it possible to use AJAX in JavaScript to dynamically update page titles?

When loading a new page using AJAX, I am having trouble updating the title. The expected titles should be "Home", "About", and "FAQ". I attempted to solve this by changing the title with the code snippet below, but it only resulted in displaying "undefine ...