Xhynk
Xhynk

Reputation: 13890

Incrementally increase max/min-height: of a div?

So I have a content div that looks best at incremental heights of 400px.

If the content varies in size, the bottom looks funny ie, if it's 638px tall due to the content inside. However if it's 800px it looks great (same for 1200 and 1600, etc.)

Is there a way to do a #div { min-height: 800px; } but if there is even 801px of content, make it snap to #div { min-height: 1200px; } with CSS or Javascript?

Upvotes: 0

Views: 254

Answers (1)

Cyclonecode
Cyclonecode

Reputation: 30131

Something like this?

// set the height of a div with an id of 'test'
$(document).ready(function() {
 var height = $('#test').height();
 if(height % 400) {
     height = height - (height % 400) + 400;
 }
 $('#test').css('height',height+'px');
});

Upvotes: 2

Related Questions