Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3.1.0: affix too long

I am using Bootstrap 3.1.0. When an "affix" gets too long for the viewport, it gets cut off, never showing bottom items.

Is there a possibility to have Bootstrap's affix behave in a way that it is still possible for the user to scroll the complete affix from top to bottom?

Problematic example:

<div class="container">
    <div class="row">

        <div class="col-md-3">
            <div class="list-group" id="sidebar">
                <a href="#" class="list-group-item">Long</a>
                <a href="#" class="list-group-item">list</a>
                <a href="#" class="list-group-item">with</a>
                <a href="#" class="list-group-item">many</a>
                <a href="#" class="list-group-item">entries</a>
                ...
                <a href="#" class="list-group-item">29. Last</a>
            </div>
        </div>

        <div class="col-md-9">
          ... regular content    
        </div>

    </div>
</div>

I hope my jsFiddle exemplifies this problem.

like image 520
Abdull Avatar asked Feb 11 '14 01:02

Abdull


1 Answers

I hope it can help you :

Just add an overflow-y

Jsfiddle : http://jsfiddle.net/Ja3XT/1/

Added Css :

#sidebar{
 max-height: 100%;
 overflow-y: auto;   
}

UPDATE AFTER COMMENT:

fiddle : http://jsfiddle.net/F4FZL/1/

JS :

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


$('#sidebar').on('affixed.bs.affix', function(){
    $(this).removeAttr('style');
});
like image 98
BENARD Patrick Avatar answered Sep 29 '22 23:09

BENARD Patrick