3

I'm using Bootstrap Affix like this :

<div data-spy="affix" data-offset-top="220">

And i add this css for fix the position when affix is triggered :

.affix {
        position: fixed; 
        top: 20px; 
        z-index:1;
        margin-left: auto ; 
        margin-right: auto ;
    }

Is it possible to use the Affix on several Dom element and affect a different css, something like this :

<div data-spy="affix2" data-offset-top="220">
.affix2 {
            position: fixed; 
            top: 50px; 
            z-index:1;
        }
Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
mcbjam
  • 7,344
  • 10
  • 32
  • 40

1 Answers1

7

You could make specifiers for the 2 divs..

HTML

<div id="affix1" data-spy="affix" data-offset-top="220">..</div>
<div id="affix2" data-spy="affix" data-offset-top="220">..</div>

CSS

#affix1.affix {
    position: fixed; 
    top: 50px; 
    z-index:1;
}

#affix2.affix {
    position: fixed; 
    top: 200px; 
    z-index:1;
}

Here's a demo: http://bootply.com/63178

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624