Ad
Bootstrap 4 Sticky-top Not Working Properly
I need to make the sidebar stick to the top. This works when the screen is smaller than the sm
breakpoint, but larger than that, it doesn't stick. I thought the culprit could be the order of the class names, so I tried moving them but same results.
sticky-top
works with col-sm-*
but not with col-*
. Why?
My code is in HAML and SCSS, I hope that's okay. Refer to this pen
.container
%ul.nav
%li.nav-item
%a.nav-link{:href => "#"}
Menu
%li.nav-item
%a.nav-link{:href => "#"}
Active
%li.nav-item
%a.nav-link{:href => "#"}
Link
.row
.col-sm-3.sticky-top#sidebar
This sidebar should stick to the top, both in expanded view and stacked view.
.col-sm-9#main
This main will continue scrolling until the bottom while the sidebar will stick to the top.
This main will continue scrolling until the bottom while the sidebar will stick to the top.
This main will continue scrolling until the bottom while the sidebar will stick to the top.
This main will continue scrolling until the bottom while the sidebar will stick to the top.
CSS
html, body {
margin: 0;
height: 100%;
}
.container {
height: 120%;
box-shadow: 2px 2px 10px;
.row {
> #sidebar {
background:#ccc;
}
> #main {
background: #eee;
}
}
}
Ad
Answer
The #sidebar
is as tall as the content, so there is no space for the sidebar to fix... so add .align-self-start
to your #sidebar
Ad
source: stackoverflow.com
Related Questions
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → laravel blade templating error
- → should I choose reactjs+f7 or f7+vue.js?
- → How to dynamically add class to parent div of focused input field?
- → Setting the maxlength of text in an element that is displayed
- → Undefined Result for Variable with Javascript innerHTML function
- → Expanding search bar not expanding before search
- → Get the calling element with vue.js
- → Blade: how to include a section in one page but not in another
- → How to print/log reactjs rendered dom?
- → how to write react component to construct HTML DOM
- → How to add a timer in HTML5 and Javascript?
Ad