Ferodynamics Network

popular: profile privacy, mobile privacy

January 22, 2010

Centered jQuery Tabs Shake UI Bug

I created a jQuery site a few years ago for a local psychologist. It's a tabbed jQuery design I put together to replace an old Wordpress install. While the updated jQuery design looks more modern than the Wordpress-as-a-CMS design it replaced, that was not the primary reason for the overhaul.

What prompted me to switch to jQuery? I was moving from Site5 to Media Temple, and as you may know, importing/exporting Wordpress databases is not fun. Not difficult, but time-consuming and a tad dangerous. I thought it would be easier to simply redesign the site from scratch in jQuery. And I was right. The new jQuery site is essentially one file that contains the content of all six tabs. One file is easy to manage and easy to move to a new host. Much easier than a Wordpress install that needs regular security updates, a new database password, etc. OK, one file not including the jQuery library files, but you get the idea. I used jQuery's ThemeRoller to pick the colors I wanted. No laborious tweaking of RGB hex values.

What's Shaking?

The move to Media Temple went fine. Years passed. Then yesterday a friend told me his uncle might need a website. I decided to check on that old jQuery site. Started playing with the tabs. What's this? The third tab shifts the entire page a pixel or two to the right or left, coming and going. The 4th tab doesn't, the 5th does, something like that. Hover the mouse over each tab in sequence and you get the undesired "shake" effect. It's even more noticeable because I'm using a jQuery mouseover event to activate the tabs without requiring a click.

Why does it shake now, when it didn't shake before? Browsers change. New Firefox. New Google Chrome. But the page uses jquery-1.3.1, that hasn't changed. Maybe a new version solves this problem?

Upgrading to jQuery 1.4 was easy. I simply changed this (index.html) line:

<script type="text/javascript" src="http://pjbrunet.com/jquery-1.3.1.min.js"></script>

to this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>

Same problem. (In case you're wondering, I reverted back to 1.3.1.) Turns out this is a UI bug, but "no date set" for a fix.

Position:fixed Workaround

It appears the source of the problem is the "auto" margin. This was the problem for me:

<body style="background-image:url(body_bg.gif);width:713px;margin:0 auto;padding:20px;">

Maybe I could drop in the ancient "center" tag and that would solve everything. Well, I'm not sure if this solution is any more valid with its negative margin, but it works:

<body style="background-image:url(body_bg.gif);width:713px;position:fixed;margin-left:-356px;left:50%;padding:20px;">

Notice the negative margin is (approximately) half of the width of the body.



Covert Facebook Tracking
586 comments
page 48
Covert Facebook Tracking
586 comments
page 48
Covert Facebook Tracking
586 comments
page 48
Covert Facebook Tracking
586 comments
page 48
Peace Symbols And Hearts
10284 comments
page 77
Covert Facebook Tracking
586 comments
page 48
  updated 1 seconds ago
I'm on Twitter @ferodynamics and follow tweets:
20143
Zee
In the middle east? Read this ---> No News is Bad News (link) by @FawziRahal on @TNW_ME
392
AddTips
Windows 7 Orb Changer : Change Start Button (link)
336
FreshlySkweezed
Well, just popped in for a little " hello " and now I'm heading out to breakfast with a friend. Doing a little shopping, too, before the snow.
1343
amykate
RT @RdgGeek: Fourth talk for tonights #rdggeek " How to screw up every project you ever work on? (link) - 7.30pm at Copa in #rdg
36768
Szetela
4 Tips For Getting Out Of Your #PPC Rut (link)
5614
dalmaer
Some folks were saying that you can't do good failback to Flash with HTML5 video but you can! Make sure to use type="" (link)
441
cpierret
It 's seems Apple is pushing ruggedized iPhone solutions a lot! Beware Motorola / Symbol, Intermec and Psion - Teklogix!
17291
Econsultancy
How to control SEO spending post - recession (link)
20143
Zee
Telefonica Considers Charging Google For Bandwidth (link) by @TimDifford on @TNW_EU
18197
chrisgarrett
ha @mikecj yeah because they couldn't print out a tif on laser printer and get the exact same frikkin effect ;)
18198
chrisgarrett
I might see how much it is to send the letter via pigeon...
411
refreshaustin
New Topic : Texas Coworking Video Conference Event : Boagworld 200 : Texas Coworking Video Conference Event : Boagworl... (link)
3197
TechmemeFH
comScore Reports December 2009 U.S. Mobile Subscriber Market Share ( comScore, Inc.) (link)
582
johngriffiths7
a new use for a google wave - a list of products so brilliant and so intuitive that they never caught on
434
wpkid
RT @wordpressdotcom: Posterous Importer (link) #wordpress
1302
kfeighery
" Customer Lifetime Value Tool " ( (link) )
18198
chrisgarrett
Seems Share a Sale is based in 1989... " please fax a signed letter stating that fact to " - WTF?
3197
TechmemeFH
Check out Techmeme 's sponsors on Twitter : @bizspark @RackApps @ch9 @google @seesmic @intelswblog
5300
LadytronMusic
This month Mira DJs : Puebla, Mx City, Miami, Cleveland, LA, Ottawa.
3353
litmanlive
Nice find. Here 's the original article. RT @canofpopcom For those who missed it (link)
3728
grahamdbrown
RT @MarketingPub: India? world?s largest mobile youth market (link)