Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Really weird "redraw behavior" with anchor links, twitter bootstrap fixed-navbar and affix plugin

I'm experiencing an extremely weird behavior when using Twitter Bootstrap's affix plugin, fixed navbar, and anchor links together. I'm going to attempt to explain my problem but it's kind of difficult to put into words, so please forgive me if I'm not the clearest.

I have a navbar-fixed-top at the top of my page. Under that I have a .container div. Inside there I have two div.spans (span4 and span8). Inside span4 is a div.well that has the affix-top class applied to it (so it gets a fixed position and "sticks" where it's at). Inside my span8 I have a bunch of content.

Inside the well div there is a nav-list. This list gets populated with li/a elements based on items in the span8 (I have a little script that does this). The links are anchors, so they point to elements on the page (#myId, #myIdTwo, etc). All this works wonderfully. My list is there, the links are clickable, they take me to my elements. Great.

However, not great. Sometimes, when I click one of the links, I go to my anchor in the span8 but the page doesn't seem to refresh properly. I sometimes see strange white "boxes". Or the content inside the span will show partly above the fixed nav-header. Sometimes half of the nav-list disappears.. but then comes back (sort-of) if I move my mouse around it. Like you used to see in some old Windows applications that were getting bogged down.

You can see for yourself here: http://jaylach.github.com/lutra. You may need to click some of the nav links a few times before you see the issue.

I've been struggling with this all day and I cannot, for the life of me, figure it out. I've taken out the affixes, I've taken out the fixed top navbar, I've taken out my z-index. I just can't seem to figure it out.

Does anyone, anywhere, have any clue as to what could be causing this? I would really appreciate any advice you guys could give.

Many thanks in advance!!

like image 540
Jason L. Avatar asked Jan 24 '13 03:01

Jason L.


1 Answers

This is a WebKit bug.

add -webkit-transform: scale3d(1,1,1); to both .navbar-fixed-top and .affix

both styles are defined in bootstrap.min.css. So override these 2 styles in your main.css as:

.affix,.navbar-fixed-top {
-webkit-transform: scale3d(1,1,1);
}
like image 151
aju Avatar answered Sep 20 '22 01:09

aju