I have a row with two columns - one to the left (with a jar), and another to the right (with buttons).
https://codepen.io/OakTreePedro/full/NEEVxr
When the screen is large, I have them side by side, and to see all of the right columns' contents, I have to scroll down. When I do so, I want the contents on the left column to follow that scroll, and that isn't currently happening.
Basically, when trying to select a filter from the bottom of the right column, I want the jar on the left column to accompany the scroll-down.
I've already tried a number of things:
I've tried to use media-queries - if the screen's
min-width
was992px
, I would apply aposition: fixed
or aposition: sticky
to the left column;I've tried using JavaScript - on
window.resize()
, if theinnerWidth
was>= 992
, I would applyposition: fixed
orposition: sticky
to the left column'sstyle
, orclassList.add(position-fixed)
/classList.add(position-sticky)
/classList.add(sticky-top)
;I'm currently trying to use
stickyfill
with the aforementioned solution to achieve my goal but to no avail.
Here's my code:
https://codepen.io/OakTreePedro/pen/WLyBqp
HTML:
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6 col-xl-6 animated slideInLeft" id="jar-section">
CSS:
.sticky-jar-section {
position: -webkit-sticky;
position: sticky;
top: 15px;
}
JavaScript:
var jar_section = document.getElementById("jar-section");
window.onResize = function() {
if (window.innerWidth >= 992) {
jar_section.classList.add("sticky-jar-section");
Stickyfill.add(jar_section);
} else {
jar_section.classList.remove("sticky-jar-section");
Stickyfill.remove(jar_section);
}
};
I expect the left column to follow the scroll, like in this example (not mine):
https://codepen.io/tutsplus/pen/pJRRKW
EDIT because I've made a mistake when copying the code here and forgot the double-quotes around a class.