Page 1 of 1

Height snap to grid.

Posted: Wed Apr 18, 2007 5:48 pm
by JellyFish
How could I, with jQuery, have the height of a div snap to a grid of 325 when ever resized? Always rounding up never down.

For example:

Let say the height of the div is 300px round it up to 325px. Another instance: Let's say the div is 326px, round it up with jquery to 650px.

I hope you get it. I'm just lost on where to start...

Please help me wit this one. :?:

Posted: Wed Apr 18, 2007 6:03 pm
by Weirdan
snapping formula is simple:

Code: Select all

$snapped = ceil($original / $snapsize) * $snapsize;

Posted: Wed Apr 18, 2007 6:14 pm
by JellyFish
Um. Those are php functions and variables? What's the equivalent to ceil() in JavaScript? Math.ceil()?

PS: LP ROCKS!!! :twisted:

Posted: Wed Apr 18, 2007 6:20 pm
by Luke
linkin park is terrible

Posted: Wed Apr 18, 2007 6:27 pm
by JellyFish
The Ninja Space Goat wrote:linkin park is terrible
That's your opinion...

Anyways, I used the Math method and it works like a charm. Thanks Weirdan! :D

I'm going to go listen to some Linkin Park now. :lol: