25 01/2010Damien Buckley Firefox & Safari incorrectly sizing table on hide/show

Data tableI came across an odd bug while working on a hide/show behaviour with a data table, specifically a set of summer / winter ferry timetables.

The tables in question have a fixed width and render perfectly without the hide/show mechanism and also (bizarrely) render correctly with the hide/show engaged in IE(Internet Explorer) but in Firefox and Safari, we get an odd gap on the right hand side of the table.

I’m using a simple jQuery slideToggle function which works perfectly elsewhere but in this case the data tables were creating a bug somewhere.

After checking the markup thoroughly and ensuring the page validated I spent an hour or so tooling around with the CSS to ensure I wasn’t causing the problem myself but to no avail.

I finally came to the conclusion that the faulty browsers are incorrectly calculating the table cell widths when switching from display:none to display:block.

Data tableI eventually resolved this by wrapping the table in a div and collapsing that instead of the table itself. Not exactly the most streamlined approach but it works.

Original code…

<table id="winter"…

Working code…

<div id="winter"><table…

Hope this helps if you encounter the same problem and would love to hear if anyone has a solution without the additional markup.

Happy hunting.

Like this? Share it…

1 Comments

  1. Simon Foust commented at 19:52 PM on 25 Jan 2010

    Wow nice catch. It’s definitely surprising when IE gets something right!

    On another note, imagine how much easier our job is going to be in a few years when we won’t have to rely on jQuery to do stuff like this. Can’t wait!

Recent Projects

  • Vote 1 Bruce Smith

    Bruce Smith

    Local Business Operator and RedFest Chairman Bruce Smith is campaigning for election to Redland City Council Division 6 in 2012.

  • Kids Outdoor Gear

    Logo Design for Kids Outdoor Gear

    This was such a fun project!

    The brief was to create a fresh logo and stationery package for Kids Outdoor Gear – a wonderful company that sells everything active kids need for play in the great outdoors.

  • Stradbroke Island Events

    Stradbroke Island Events

    Only one-hours ferry trip from Brisbane, North Stradbroke Island is a stunning destination, rich in wildlife and incredible natural scenery. It comes as no surprise then that Straddie as it is affectionately known by the locals is a prime destination to hold events; proposals, engagements, weddings, anniversaries, birthdays, corporate retreats…

  • Vote 1 Louise Denisenko

    Louise Denisenko Campaign Website

    Local Business Operator and Victoria Point Resident Louise Denisenko is running for Division 4 in the 2012 Redland City Council elections.

Get The Latest!

Subscribe to our free e-newsletter for our latest news and offers - direct to your inbox.