Jquery/JS whiz?
- Started
- Last post
- 25 Responses
- Noggin
I posted a question regarding an age old problem with equal height divs last week without a decent solution.
http://www.qbn.com/topics/639225…
I found some jquery code that will do it elegantly with one issue - it wont work for multiple rows. It will set ALL the divs to the same height as opposed to a 'per row' basis.
http://www.cssnewbie.com/example…
Any whiz out there who can change it from an 'id' solution to a parent/child solution?
- acescence0
you could just give them different classes and target them separately
$(".block").equalHeights();
$(".block2").equalHeights(800);
$(".block3").equalHeights(100,50...
etc..
- Noggin0
The page may contain like 20 boxes (say 10 rows each with 2 boxes in), that will probably be generated from a database so giving each box an id/class name wont work.
- robot520
if there are only 2 boxes per row, write a loop that compares the heights of the even-th and odd-th. adjust the heights to whichever has the greatest.
- Noggin0
You sir, are a fucking genius. Thank you.
I hope this comes in useful for other people too.
- acescence0
sorry, this will fail miserably if you have any other divs within the rows, change the $("div",this) selectors to $(".block",this)
- monNom0
the correct answer:
"fuck-it, use a table"
- bigtrick0
damn acescence.. you are not only a good js hacker, but a good samaritan too.
- Noggin0
Dear Acescence,
Ive had to come back for another fix for this. I figured with your solution I dont need the bg image hack anymore since I can just use a bg in each box.
Doesnt work that way tho as its the containing div that is being auto-height adjusted (the one with the bg image hack).
Is there a way to auto height the box itself?
- Noggin0
I should add that right now its the box is contained within 2 divs (one of which uses the bg image 'hack').
Tried to make sense of the JS but I guess I dont make the grade.
- acescence0
i'm not sure i understand. the containing div should be the same height as the tallest child div after you clear the floats.
- spraycanII0
for parsing some sql request , Tables. All the time divs is a waste of time. fuck code
- robot520
you should post a link to your site or dump a sample in pastebin.
- Noggin0
Heres the barebones version...
http://s90652007.onlinehome.us/b…
So I want the the content_box to be 100% of its surrounding div and will have a bg image.
- acescence0
so it's basically the same, you've just added another surrounding div?
- acescence0
no worries, only took me a second, though your offer is appreciated!