How to leave a 'fixed' div bounded by a main div?

0

I'm trying to do something like this: link where the div containing the values of the purchase is fixed only while the customization options are visible, but I believe that it is not possible to do this with 'fixed', the only thing I have managed to do so far is to leave this 'box' with values fixed throughout the page.

Would anyone suggest a solution?

    
asked by anonymous 08.10.2014 / 15:19

3 answers

2

You can use the jquery Sticky-Kit plugin.

  

Sticky-kit fixes the elements on the page when the user scrolls so that this element is always visible.

     

With it just select an element and apply a function:

$("#sidebar").stick_in_parent();

Practical example:

link

    
08.10.2014 / 15:56
0

You can try using jQuery:

$(window).bind('scroll', function() {
     if ($(window).scrollTop() > POSIÇÃO_Y) {
         $('.sua_div').addClass('fixed');
     }
     else {
         $('.sua_div').removeClass('fixed');
     }
});

So, whenever the scroll of the page goes from POSIÇÃO_Y , the div will have the class .fixed , there in CSS you declare this class to div with position: fixed

    
08.10.2014 / 15:55
-1

Just create a div fixed that appears and disappears using display:none . This also happens in pc gamer .

    
10.12.2018 / 13:25