2

I am a beginner to Magento 2 and want to make a sticky sidebar when scrolling down like a cart page summary. I try using jQuery but not working for me. Can anyone help me? https://i.stack.imgur.com/w9L0I.png

3

Use Magento 2 sticky js for this one. Create custom js in your theme and add the below code. Create a custom JS in your theme:

app/design/frontend/[Vendor_Name]/[Your_theme]/web/js/your_custom.js

Add the below code in your theme JS

define([
"jquery",
"mage/sticky",
], function ($) {
    'use strict';
    $(document).ready(function () {
        $('.sidebar.sidebar-additional').sticky({
            container: '.columns',
            spacingTop: 100,
            stickyClass: '[sticky-class]'
        });
    });
});

Note: You can edit spacingTop and stickyClass as per your requirement. I hope it will work for you.

2
  • thanks for your help its working fine....@Vikram Kumar – Suraj Prajapat Sep 7 '20 at 11:42
  • 1
    My pleasure. Always ready to help. – Vikram Kumar Sep 7 '20 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.