iCediCe
iCediCe

Reputation: 1722

Stickysidebar within container

Affix is giving me a hard time. I'm trying to create a sticky sidebar that only follows within the bounds of the container.

The sidebar should stick to the top of the screen as long as it's within the containing div.

See my horrible attempt here: http://codepen.io/icedice/pen/OMrPwz

I'm using $('#sidebar').affix();

Is this possible with affix or how do i proceed?

Upvotes: 0

Views: 66

Answers (1)

Carol Skelly
Carol Skelly

Reputation: 362360

You need to use the offset.bottom option so that affix-bottom gets set on the sidebar...

$('#sidebar').affix({
    offset: {
      top: ..,
      bottom: ..
    }
});

http://codeply.com/go/sv7l3DDGtO

Upvotes: 1

Related Questions