Make div sticky with Bootstrap

I am using Bootstrap v3 for a div that I would like to make it "sticky" after scrolling from its current position, either moved left or left.

<div id="trigger1">
    <table class="nav-justified">
        <tr>
            <td>
                Menu Area
            </td>
            <td>
                <div class="text-right">
                    <div class="dropdown">
                        <a id="FilterDataLabel" class="btn btn-danger" data-target="#" data-toggle="dropdown" href="#" role="button">
                            <span aria-hidden="true" class="glyphicon glyphicon-filter">
                            </span>&nbsp;&nbsp;Filter Filter Menu
                        </a>
                    </div>
                </div>
            </td>
        </tr>
    </table>
</div>

      

+3


source to share


2 answers


You need to use CSS attribute position: fixed;



Check out this example: jsFiddle .

+1


source


It sounds like you want to be div

placed somewhere on your page, and when the page scrolls, div

will stick to the top. If this is correct, you can use it ... affix

.

Here is a Fiddle when it does it with sticky div

.



Try this and use what you code here.

<script>
$('.stick-top').affix({
  offset: {top: 50}
});
</script>

      

0


source







All Articles