Navigating with Bootstrap 4 Side Menu

I've been studying the Bootstrap 4 documentation and noticed an interesting feature - a left-aligned navigation bar that stretches to the full height of its parent while the main content scrolls in the center. Despite my best efforts to replicate this design using Bootstrap 4 utility classes, I'm unable to achieve the same full-height effect for my column. Any suggestions on how to implement this successfully?

Answer №1

It appears that the website is utilizing custom CSS instead of pre-built Bootstrap classes.

Upon inspecting the element, a class named bd-sidebar can be observed within the main container's CSS rules containing the following code snippet:

@media (min-width: 768px)
.bd-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 4rem;
    z-index: 1000;
    height: calc(100vh - 4rem);
}

Breaking down the aforementioned code: The first line signifies a media query targeting screen widths of 768px or higher.

The position:sticky property is thoroughly explained in this resource: https://css-tricks.com/position-sticky-2/. The prior line includes a vendor-prefixed version for compatibility purposes.

top:4rem shifts the element downward by 4 relative ems as described here: 'relative ems', ensuring clearance with the top navigation bar.

z-index:1000 ensures visibility priority above and below specific content on the page.

Now, for the ingenious part!

height: calc(100vh - 4 rem)

This calculation subtracts 4 relative ems (representing the height of the nav bar) from 100vh. A viewport height (vh) measures a percentage of the full viewport height. For instance, 10vh would equate to 10% of the current viewport height (as per https://css-tricks.com/fun-viewport-units/)

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

Displaying a div upon clicking a hyperlink

I am currently working on designing an unordered list that serves as a family tree. My goal is to enable users to click on each section, triggering the appearance of a new div in the center of the screen containing relevant details about that specific pers ...

Exploring the data-* attribute in jQuery

Currently, I have a form structured as follows: <div data-role="page" data-last-value="43" data-hidden="true" data-bind='attr : {"name":"John"}'></div> My objective is to modify the name attribute from "John" to "Johnny". I am att ...

The Phaser timer doesn't update the object's position, just its coordinates

I'm currently working on a Phaser game where I want the character's physics size to change when the down arrow is pressed, and then revert back after 1 second. The code I wrote successfully changes the physics size, but there's an issue whe ...

The function mysql_fetch_assoc is displaying absolutely nothing (neither null, nor 0, nor an empty string)

I'm encountering an issue with retrieving data from my $result variable. Everything works smoothly when there is one result, but if I try to check for a result and find none, the $array ends up empty. Running both commands below results in nothing bei ...

Preserve the location of a moveable div using jQuery

I have implemented draggable divs in my JSP page, allowing users to move them around freely. After dragging the divs, I would like to save their positions either in a cookie or database for future reference. Could you please advise on the best way to ach ...

In Bootstrap 4, the text exceeds the boundaries of the card

I am looking to overlay text on an image using the bootstrap card-img-overlay feature. Here is the code I have written: <div class="h-100"> <div class="card h-100"> <img class="card-img" src="../imgs/header.jpg" alt="Card image"& ...

Preventing Body Overflow Without Affecting Iframe Overflow in Meteor.js

Currently, I am working on a project using Meteor for a Point of Sale (POS) system. For those unfamiliar with it, Meteor is a framework that allows for the use of JavaScript, jQuery, and various other web app scripting languages. The goal of this applicati ...

Maintain consistent dimensions for Bootstrap cards by adjusting column count to achieve equal width and height

I am attempting to define the number of columns for a bootstrap card deck in order to achieve uniform width and height for each card. The height should adjust dynamically based on the content of the card body, similar to how a card deck works, while maint ...

Tips for choosing classes with identical names without resorting to incremental IDs

https://i.stack.imgur.com/EVQVF.pngAre there alternative methods to select classes with the same name but in different table rows? Currently, I am using html class="className + id" and then in jquery to select $('.className'+id)... some code. Is ...

Trouble with flex wrap in my design template using Material UI

How can I create a responsive template using flexbox wrapping method? <Box sx={{ padding: 0, margin: 0, listStyle: "none", display: "flex", flexFlow: ...

Where can I locate the definition of a div in WordPress?

Recently, I installed a new template on my WordPress blog. However, the template designer added a footer copyright that I am unable to delete. It seems like the copyright text is not located in any of the PHP or CSS files. Upon inspecting the elements, I f ...

Reposition the div element on mobile devices using media queries

Hello, I'm facing an issue on mobile with my website: dev site Today, I implemented a dropdown menu with flags to allow language switching. However, the dropdown in mobile is appearing under the hamburger nav bar. I was thinking of using media querie ...

Position the Bootstrip 4 tooltip to automatically display on the right side

In order to customize the placement of my tooltip on desktop, I have opted for having it positioned on the right side of the elements. While this choice aligns well with my design preferences, it has presented a challenge when viewing the page on smaller s ...

Concealing and Revealing a Div Element in HTML

Every time the page is refreshed, I am encountering a strange issue where I need to double click a button in order to hide a block. Below is the code snippet for reference: <!DOCTYPE html> <html> <head> <meta name="viewport&quo ...

Guide for including a script reference in an HTML file through a Windows .BAT file

Looking to add a script reference to an HTML file using a Windows .BAT file Here's the code I've attempted: for %%f in (*.txt) do ( for /f "eol= delims=" %%v in (%%f) do ( if "%%v"==">Line-X" ( echo %%v>> %%f2 echo ^& ...

Use Javascript to deactivate the mouse cursor and rely solely on the keyboard cursor for navigation

I am facing an issue with a div that contains a textarea. The cursor is automatically positioned at the beginning of the text within the textarea. I would like to disable the mouse cursor when hovering over the textarea but still be able to navigate within ...

Having trouble with GSAP Scrolltrigger PIN functionality in Next.js?

When I comment out the pin: true property in my code snippet below, everything works as expected except that the container wrapping the sections that should scroll horizontally does not stick to the top. However, if I uncomment the pin: true line, the enti ...

The dropdown feature in Bootstrap 5 seems to be malfunctioning in Angular 12

I am facing issues while trying to implement the Bootstrap 5 dropdown in Angular 12. After installing all required packages and adding them to the angular.json file, I still cannot get it to work properly. Even after copying the example directly from the ...

After resolving the parentModal issue, Select2 disabled the modal upon requesting data via AJAX. How can I reactivate the modal?

Currently utilizing the select2 jQuery plugin for option searching. Upon selecting a specific option, I am utilizing the onchange event listener in JavaScript to trigger a function that searches data on the backend. I then return the HTML component view re ...

Using Bootstrap to create a grid layout with an image

Where can I find a custom bootstrap grid similar to the one shown in the image below, with the red square being an image? https://i.sstatic.net/rgg0H.jpg I attempted to use this code but it didn't give me the exact outcome. How can I modify it to ac ...