Skip to content

Instantly share code, notes, and snippets.

@schjetne
Created August 20, 2012 15:30
Show Gist options
  • Save schjetne/3405181 to your computer and use it in GitHub Desktop.
Save schjetne/3405181 to your computer and use it in GitHub Desktop.
Prevent images from disrupting vertical flow
// Prevent images from disrupting vertical flow
$(window).resize(function() {
var fontSize = parseInt($('body').css('font-size'),0);;
var lineHeight = parseInt($('body').css('line-height'),0);;
$('.baseline').each(function() {
var heightDif = $(this).outerHeight();
$(this).css('margin-bottom', fontSize + heightDif % lineHeight);
});
});
$('.baseline').load(function() { $(window).resize(); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment