My goal is to create a fixed sidebar

I have successfully created the sidebar, but I am looking to make it fixed with a vertical scroll bar.
The desired outcome can be seen here: https://i.sstatic.net/3c9zD.jpg

My attempt at achieving this was unsuccessful:

<div class="col-md-4 bg-light px-0">
                <div class="sidebar px-3">
                    <h3 class="mt-4">Rental</h3>
                    <h3 class="mt-2">from $99</h3>
                    <p class="mb-5">per night</p>
                    <form action="">
                        <p><i class="fa fa-calendar-check-o pr-1"></i>Check in</p>
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="DD MM YYYY" required>
                        </div>
                        <p class=""><i class="fa fa-calendar-o pr-1"></i>Check out</p>
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="DD MM YYYY" required>
                        </div>
                        <p class=""><i class="fa fa-male pr-1"></i>Adults</p>
                        <div class="form-group">
                            <input type="number" class="form-control" placeholder="1" required>
                        </div>
                        <p class=""><i class="fa fa-child pr-1"></i>Kids</p>
                        <div class="form-group">
                            <input type="number" class="form-control" placeholder="0" required>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="form-control btn btn-success w-100"><i
                                    class="fa fa-search pr-3"></i> Search availability</button>
                        </div>
                    </form>
                </div>
                <div class="hoverablediv">
                    <div class="py-3 p-3"><a href="#" class="text-decoration-none text-dark"><i
                                class="fa fa-building pr-1"></i>Apartment</a></div>
                    <div class="py-3 p-3" data-toggle="modal" data-target="#myModal"><a href="#"
                            class="text-decoration-none text-dark"><i class="fa fa-rss pr-1"></i>Subscribe</a></div>
                    <div class="py-3 p-3"><a href="#" class="text-decoration-none text-dark"><i
                                class="fa fa-envelope pr-1"></i>Contact</a></div>
                </div>
                
            </div> 
</div>

Answer №1

In case your body has a z-index value of 0, you can include

position: fixed;
overflow: auto;
z-index: 1;

or alternatively (if you prefer the sidebar to always display a vertical scrollbar)

position: fixed;
overflow-y: scroll;
z-index: 1;

within your sidebar's css styling

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

The brand in the Bootstrap 4 navbar remains consistent even when the screen is maximized

Having an issue with my navigation bar design. I'm currently working with Bootstrap 4 Beta and facing a problem when trying to adjust the navbar-expand-... The current appearance of the navbar-brand looks like this: COMPANY NAME However, I want it ...

Having trouble retrieving data from an API using jQuery

My question pertains to an HTML form: <!DOCTYPE html> <html lang="en> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=1.0, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=e ...

Input element enables simultaneous input and output

Currently, I have a web audio player set up with a basic simulation of how the seekbar functions. The progress bar displays the advancement of the audio track, while an input bar appears on hover to enable user interaction. My issue lies in the fact that ...

How can the AJAX request be adjusted to ensure that the dependent drop-down is hidden when the page initially loads?

My current form includes a dependent drop-down feature. Right now, both the main drop-down and the dependent one are displayed when the page loads. If a "Work Area" without a "Station" is selected, then the station drop-down disappears. What I want to acc ...

Setting up a ClientBundle in GWT with multiple CssResources

I am currently in the process of updating some older code to GWT 2 and encountering some strange behavior. I have a custom interface that extends ClientBundle, as recommended by the GWT documentation. Within this bundle, I have defined multiple CssResource ...

Ways to address time discrepancies when the countdown skips ahead with each button click (or initiate a countdown reset upon each click)

Every time I click my countdown button, the timer runs normally once. But if I keep clicking it multiple times, it starts skipping time. Here are my codes: <input type="submit" value="Countdown" id="countdown" onclick="countdown_init()" /> <div i ...

Is it possible for 'will-change' to achieve the intended outcome when implemented using the Web Animations API?

Google recommends: Google suggests that if an animation may occur within the next 200ms [...] it's a good idea to use will-change on elements being animated. In most cases, any element in your app's current view that you plan to animate should ...

Creating a custom image picker tailored for specific content

As I embark on creating a new page, my goal is to choose an image from a collection of previously uploaded images. Despite hours spent searching for a viable solution, I have come up empty-handed. I am well-versed in the process of uploading and displaying ...

After pressing the login button, my intention is to transition to a different page

I am relatively new to web development and working with angular. I have a login component that, upon hitting the LOGIN button, should redirect to another component on a different page. However, currently, when I click the button, it loads the data of the o ...

What is the best way to make a hamburger menu appear on the right side of the screen?

After working tirelessly on converting one of our websites to be mobile-friendly, I've hit a roadblock. While the standard approach is to place the hamburger menu on the left and have the content slide to the right, I'm interested in doing the re ...

How to eliminate bullets from an unordered list using Bootstrap

Struggling to get rid of the bullets displayed on an unordered list using Bootstrap. I attempted utilizing the "text-decoration-none" class without success. ...

Steps for locating the initial instance of content within a DIV

The HTML code below shows information about different types of surgeries: <div class="provInfoSub hidOverflow floatLeft vertAlignT"> <specialty><a title="Plastic Surgery" href="check.aspx">Plastic Surgery</a></specialty> ...

Fixed navbar at the top changes from absolute positioning to relative when scrolling

My goal is to dynamically change the position of the navbar from fixed to absolute as the user scrolls past 600px. Initially, I used the following code: if (scroll >= 700) { $(".navbar-fixed-top").addClass("navbar-scroll"); } else { $(".navbar ...

Discovered a critical vulnerability that requires your attention. Execute `npm audit fix` to resolve the issue, or use `npm audit` for more information

After attempting to install mysql using 'npm install mysql', I encountered an error message stating: "found 1 critical severity vulnerability run npm audit fix to fix them, or npm audit for details" Following this, I proceeded with 'npm au ...

Prevent VueJS form from submitting when the enter key is pressed

Is there a method in Vue.js to prevent form submission when the enter key is pressed inside an input field? I have a basic form with a button and an input field, and I currently handle submission using @submit.prevent="submitFunctionClickFunction". ...

Setting the Default Value for Dropdown Options in Angular 2

Back in the Angular 1 days, I had a trick up my sleeve for setting the default option on a dropdown menu: <select data-ng-model="carSelection" data-ng-options = "x.make for x in cars" data-ng-selected="$first"> </select> But now, in ...

Collapse the accordion item when a different one is selected

Check out this code snippet that's working on jsfiddle I'm attempting to add a function to close any open accordion items when another one is clicked. I've added a class "open", but I'm having trouble removing the class when a differen ...

Take charge of Bootstrap 4 dropdown transformation class while creating a Megamenu

I am currently working on creating a Megamenu using Bootstrap 4's dropdown Component. The issue I'm facing is related to Javascript adding CSS styles with transform, such as transform: translate3d(9px, 5px, 0px); This is causing disruption in m ...

How can the input within a div be iterated most effectively using this approach?

Can anyone help me figure out the best way to iterate through all input elements with a specific class within a particular div after clicking on a button? <div> <input type="text" class="inputtext"> <input type="text" class="inputte ...

Unable to retrieve data from PHP using AJAX request

My project consists of 3 interconnected files: index.php, functions.js, and compute.php In index.php, there is a div that triggers a function in functions.js called compute(), which sends an AJAX request to perform a task in compute.php The code in index ...