How to create a sticky left sidebar menu using bootstrap 3

0 votes
With the help of proper code can you tell me How to create a sticky left sidebar menu using bootstrap 3?
6 days ago in Node-js by Ashutosh
• 25,410 points
32 views

1 answer to this question.

0 votes

To create a sticky left sidebar that stays fixed while scrolling the main content, follow these steps:

HTML Structure

<div class="container-fluid">

  <div class="row">

    <!-- Left Sidebar -->

    <div class="col-sm-3 col-md-2 sidebar">

      <ul class="nav nav-sidebar">

        <li class="active"><a href="#">Menu 1</a></li>

        <li><a href="#">Menu 2</a></li>

        <li><a href="#">Menu 3</a></li>

        <li><a href="#">Menu 4</a></li>

      </ul>

    </div>

        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

      <!-- Your content here -->

    </div>

  </div>

</div>


CSS Styling

.sidebar {

  position: fixed;

  top: 0;

  bottom: 0;

  left: 0;

  z-index: 1000;

  display: block;

  padding: 20px;

  overflow-x: hidden;

  overflow-y: auto; /* Scrollable contents if viewport is shorter than content */

  background-color: #f5f5f5;

  border-right: 1px solid #eee;

}


.main {

  padding: 20px;

}


.nav-sidebar {

  margin-right: -21px; /* 20px padding + 1px border */

  margin-bottom: 20px;

  margin-left: -20px;

}

.nav-sidebar > li > a {

  padding-right: 20px;

  padding-left: 20px;

}

.nav-sidebar > .active > a,

.nav-sidebar > .active > a:hover,

.nav-sidebar > .active > a:focus {

  color: #fff;

  background-color: #428bca;

}

answered 3 days ago by anonymous

Related Questions In Node-js

0 votes
0 answers

How to create a multi-level dropdown menu in Bootstrap 3?

Can you tell me How to create ...READ MORE

6 days ago in Node-js by Ashutosh
• 25,410 points
48 views
0 votes
0 answers

How to create a responsive navbar that collapses on smaller screens in Bootstrap 3?

With the help of proper code example ...READ MORE

6 days ago in Node-js by Nidhi
• 14,200 points
35 views
0 votes
0 answers

How to create a responsive FAQ section with collapsible answers in Bootstrap 3?

Can you tell me How to create ...READ MORE

6 days ago in Node-js by Nidhi
• 14,200 points
32 views
0 votes
0 answers

How to implement a loading spinner using Font Awesome in Bootstrap 3?

Can you tell me How to implement ...READ MORE

6 days ago in Node-js by Nidhi
• 14,200 points
31 views
0 votes
1 answer

How can I implement user authentication with JWT in an Express.js app?

In an Express.js application, you can use ...READ MORE

answered Dec 17, 2024 in Java-Script by Navya
132 views
0 votes
1 answer

Is it possible to handle React events using the Chrome extension?

Yes, it's possible to handle React events ...READ MORE

answered Feb 22 in Node-js by Kavya
59 views
0 votes
1 answer

How can I use all the React events with Material-UI components?

The best approach is to leverage the ...READ MORE

answered Feb 22 in Node-js by Kavya
64 views
0 votes
1 answer

Why won't React events fire, or what could prevent them from firing?

If React events are not firing, several ...READ MORE

answered Feb 22 in Node-js by Kavya
68 views
0 votes
1 answer

How to Center a Single-Column Div Within a 12-Column Container in Bootstrap 3?

Using Bootstrap's Offset Classes Bootstrap 3 provides offset ...READ MORE

answered Mar 11 in Node-js by Tanvi
84 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP