The positioning of the left div and footer as fixed is experiencing technical difficulties

I have been trying to keep the left div and footer fixed in position while allowing the content of the right div to scroll accordingly on page scroll. In my case, I managed to fix the left div and footer, but the content inside the left div is not scrolling up or down as desired. Please refer to the attached image for a better understanding.

I want the sidebar to scroll along with the page scroll, without setting overflow-y: auto explicitly, and the footer should always remain fixed at the bottom of the page.

For further clarity, I am including a screenshot of my current implementation below.

#wrapper {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  position: absolute;
  width: 100%;
}

#sidebar-wrapper {
  height: 100%;
  padding: 0px;
  position: fixed;
  border-right: 1px solid #ddd;
  z-index: 1000;
}

#sidebar {
  position: relative;
  height: 100%;
  overflow-y: auto;
}

#main-wrapper {
  height: 100%;
  padding: 0px;
}

#main {
  position: relative;
  height: 100%;
  padding: 0px;
}

#sidebar .list-group-item {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

.footer {
  background-color: #ffffff;
  bottom: 0;
  position: fixed;
  padding: 10px 0px;
  border-top: 1px solid #ddd;
}

@media (max-width: 992px) {
  body {
    padding-top: 0px;
  }
}

@media (min-width: 992px) {
  #main-wrapper {
    float: right;
  }
}

@media (max-width: 992px) {
  #main-wrapper {
    padding-top: 0px;
  }
}

@media (max-width: 992px) {
  #sidebar-wrapper {
    position: static;
    height: auto;

   /**
   * To make this work
   */
   max-height: calc(100vh - YOUR_FOOTER_HEIGHT);

    border-right: 0;
  }
}
...and so on...

Your feedback and suggestions based on the provided image are highly appreciated!

Click here to view the working reference image.

Answer №1

Web Development -

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<!-- Latest compiled and minified CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js">
    </script>
    <div id="wrapper">
        <div class="col-lg-2 col-md-6 col-xs-12" id="sidebar-wrapper">
            <div id="sidebar">
                <div class="col-xs-12 col-sm-12 mb20">
                    <img class="profile-image" src="primage.png">
                    </img>
                </div>
                <h3>
                    General Information
                </h3>
                <ul class="profile-details">
                    <li>
                        <div>
                            <i class="fa fa-building-o">
                            </i>
                            Party Name
                        </div>
                        Congress
                    </li>
                    <li>
                        <div>
                            <i class="fa fa-briefcase">
                            </i>
                            position
                        </div>
                        Party President
                    </li>
                    <li>
                        <div>
                            <i class="fa fa-briefcase">
                            </i>
                            Winner
                        </div>
                        Rank No.1
                    </li>
                </ul>
                <h3>
                    Contact Information
                </h3>
                <ul class="profile-details">
                    <li>
                        <div>
                            <i class="fa fa-phone">
                            </i>
                            phone
                        </div>
                        +91 022 28106240
                    </li>
                    <li>
                        <div>
                            <i class="fa fa-tablet">
                            </i>
                            mobile phone
                        </div>
                        +91 9819046204
                    </li>
                    <li>
                        <div>
                            <i class="fa fa-envelope">
                            </i>
                            e-mail
                        </div>
                        <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d1f2c2538210d3f2829242b2b202c2421632e2220">[email protected]</a>
                    </li>
                    <li>
                        <div>
                            <i class="fa fa-map-marker">
                            </i>
                            current address
                        </div>
                        B-301,Akansha Tower
                        <br>
                            Naya Nagar, Mira Road - E
                            <br>
                                Dist. Thane - 401107.
                            </br>
                        </br>
                    </li>
                    <li>
                        <div>
                            <i class="fa fa-map-marker">
                            </i>
                            permanent address
                        </div>
                        B-301,Akansha Tower
                        <br>
                            Naya Nagar, Mira Road - E
                            <br>
                                Dist. Thane - 401107.
                            </br>
                        </br>
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-lg-10 col-md-6 col-xs-12 pull-right" id="main-wrapper">
            <div id="main">
                <div class="col-lg-12">
                    ht ht
                </div>
            </div>
        </div>
        <div class="col-md-12 footer">
            ht ht
        </div>
    </div>
</link>

CSS Styling -

#wrapper {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  position: absolute;
  width: 100%;
}

#sidebar-wrapper {
  height: 100%;
  padding: 0px;
  position: fixed;
  border-right: 1px solid #ddd;
  z-index: 1000;
}

#sidebar {
  position: relative;
  height: 100%;
  overflow-y: auto;
}

#main-wrapper {
  height: 100%;
  padding: 0px;
}

#main {
  position: relative;
  height: 100%;
  padding: 0px;
}

#sidebar .list-group-item {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

.footer {
  background-color: #ffffff;
  bottom: 0;
  position: fixed;
  padding: 10px 0px;
  border-top: 1px solid #ddd;
}

@media (max-width: 992px) {
  body {
    padding-top: 0px;
  }
}

@media (min-width: 992px) {
  #main-wrapper {
    float: right;
  }
}

@media (max-width: 992px) {
  #main-wrapper {
    padding-top: 0px;
  }
}

@media (max-width: 992px) {
  #sidebar-wrapper {
    position: static;
    height: auto;
    max-height: 300px;
    border-right: 0;
  }
}

Your code has been reviewed and corrected for proper implementation. Your HTML structure is now correctly organized to ensure the Bootstrap framework functions as intended.

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

Transferring a JavaScript element's ID to PHP

Recently, I came across a JavaScript function that automatically updates the date and time for me. I found the script on this URL: http://jsfiddle.net/pLsgJ/1/ setInterval(function() { var currentTime = new Date ( ); var currentHours = curren ...

Retrieve the initial N <tr> elements that contain <td> elements as their children through the power of jQuery

I am working with a <table> that contains several rows, with the first row being the header and the following 10 rows as non-header rows. My goal is to extract the top 3 non-header rows (those with td elements instead of th elements). <table> ...

Incorporating .json files into an HTML template with the help of an HTML form designed for selecting a particular

I am faced with a collection of various .json files that I wish to specify by name on an HTML page (local) form, enabling me to load this data onto a table. This is how my HTML form appears: <form> File: <input type="text" Id="file_name"&g ...

Is there a way to upload an image without utilizing or concealing the `<input type='file' />` element?

Currently, I am developing a PHP script that retrieves the directories and files from specified local computer drives. The goal I am striving for is to enable users to upload an image to my server by clicking on its name from the listing, without using th ...

Using @extend with numeric classes in Bootstrap 5: A step-by-step guide

I am looking to migrate some classes from Bootstrap 4 to 5 because some of the Bootstrap classes are no longer usable, especially in utilities. I am using SASS so I can utilize @extend for this process. https://i.sstatic.net/dEDCw.png For classes .text-l ...

How can we effectively override the automatic contrasting color determination of buttons based on their background in Boostrap v5.2 SCSS compilation?

Buttons in Bootstrap v5.2 dynamically adjust the text color based on the button color. Currently, I am modifying the bootstrap variables override file to change the primary color for my custom theme $green: #369d6d !default; $primary: $green !default; Ho ...

Searching for the dimensions of an SVG file using code - is that possible?

I have a collection of unique svg files, each containing various components. Some of these components may include "port" elements that I need to exclude when determining the overall size of the svg file. Below are examples of two different svg files with t ...

What is the best way to make this CSS arrow see-through?

My goal is to achieve this desired outcome: https://i.sstatic.net/4eTpE.png Currently, I have the following (focusing only on the left element for now): https://i.sstatic.net/nUFp1.png I am struggling to make the left arrow transparent and I can't ...

Particles.js is functioning properly in a .html file, however, it is not working in an .ejs file

I am currently working on a web development project to enhance my skills in HTML, CSS, and Javascript. I am utilizing NPM and Express for my server.js file. My goal is to incorporate Particles.js as the background on all of my pages, however, it seems to b ...

Navbar brand in Bootstrap 4 not centered when navbar is collapsed

I am currently working on aligning the brand-item and nav-items on mobile view. The alignment is incorrect in the mobile view. It is not centered. The "Brand" should be vertically aligned with "link1-3". In the desktop view, the alignment should be like ...

What is the best storage location for div elements used in jQuery Mobile pop-up functionality?

I'm struggling with what seems like should be an easy task. Even after reading through the documentation and grasping the JQM pop-up concept, I'm still stuck. It involves a simple link with: href="popupBasic" data-rel="popup" and a div with: ...

What could be causing jQuery animate to malfunction on mobile devices when a viewport is present?

Everything seems to be working fine on my desktop webpage, but when I try it on mobile, there is no scroll... $("HTML, BODY").animate({ scrollTop: 500 }, 1000); This post suggests that mobile devices may not scroll on the body, but on the vi ...

Conflicting media queries

Attempting to resolve the issue of site content overlapping with the background slider plugin on a WordPress website, I have encountered conflicting media queries for different devices. While it may work perfectly on mobile devices, it can create problems ...

Disorderly arrangement of HTML elements

I'm facing some issues with the page layout as I have to use a combination of tables and divs. The main problem arises with the footer and the div containing the table. Despite the fact that the footer is the last element inside the "main_container" i ...

Modify the drop-down value based on the selection of a checkbox in HTML

Here is the updated version that I am stuck with. <base href="http://skins4device.com"/> <link rel="stylesheet" href="/gasss/css/ghd.css" type="text/css" media="all"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.m ...

Increase the gap between vertically aligned columns in Bootstrap 4 by adding spacing

Managing vertical spacing between columns that switch from horizontal to vertical at breakpoints can be challenging. While there are solutions available when dealing with forms, applying them to multiple columns wrapping in a row can be tricky. I have atte ...

Receive the latest order details following jQuery Sort

Utilizing jQuery UI's Sortable feature, I am reordering a list of items and aiming to adjust the class of each item based on its new position. Below is the HTML structure: <ul id="sortable"> <li class="1">apple</li> <li c ...

Switch videos within the video tag as you scroll

I am trying to implement a video tag within a div element on my website. Here is the current code: <div class="phone" align="center"> <div class="phone-inner"> <video width="100%" height="100%" autoplay="" loop="" muted id="phonevideo ...

Troubleshoot: CSS Paths Broken after Deploying Django App on AWS Elastic Beanstalk

I recently deployed my first simple Django 1.8.6 application to AWS via Elastic Beanstalk. While everything appears to be working properly, the styles are not loading as expected. Below is the template code: {% load blog_tags %} {% load staticfiles %} ...

Using multiple elements with jquery insertBefore

I have created the following HTML structure: <div id="categories" class=""> <div class="list-group"> <a id="427" data-parent="{ParentId}" href="#" class="list-group-item"><i class="fa indent0 fa-caret-down"></i>Ho ...