Skip to content

Instantly share code, notes, and snippets.

@kotarok
Created February 23, 2011 12:56
Show Gist options
  • Save kotarok/840389 to your computer and use it in GitHub Desktop.
Save kotarok/840389 to your computer and use it in GitHub Desktop.
Fix the Firefox's bug that vertical margins of table elements don't collapse.
$.fn.fixFxTableMargin = function(conf){
if(!$.browser.mozilla) return this;
this.each(function(){
var elem = $(this);
elem.wrap('<div class="fixFxTableMargin" />');
var mt = elem.css('margin-top'),
mb = elem.css('margin-bottom');
elem.css({'margin-top':0,'margin-bottom':0})
elem.parent().css({'margin-top':mt,'margin-bottom':mb})
});
return this;
};
@kotarok
Copy link
Author

kotarok commented Feb 23, 2011

Use like this:
$('table').fixFxTableMargin();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment