views:

311

answers:

3

I have two div's in a container div, one floating left, one floating right. I have a php function for a search engine that spits out results, into the left div. what I need to do is have the right div repeat the background based on the height of the varied results on the left div. I have no idea how to go about this, any ideas?

Right now it looks like this:

left div content right div background
left div content right div background
left div content right div background
left div content
left div content

what I need it to do is base it's repeat-y off of the content in the left div so it looks like this

left div content right div background
left div content right div background
left div content right div background
left div content right div background
left div content right div background
left div content right div background

EDIT: The only solution I can think of right now is to spit out a blank line in the right div for every link in the left div, i'd like to avoid that, which is why i'm asking for a different solution.

EDIT 2: Thought of another way via javascript, to just detect the height after the div is loaded into the page, and reassign the height of the left to the right. something i'd like to avoid but hey what can ya do.

A: 

set the right div height as same as left div.

santose
that's the thing, it's a search result, so there is not a fixed height, so the left div could have 10 links, or it could have 5, so i can't set a fixed height
perpl3x3d
+1  A: 

As a pure css solution you can use faux columns. Basically it implies using background repeat on the parent to mask the div height. It's an ugly hack, but works surprisingly well for most scenarios.

Or you can use javascript:

var box1 = document.getElementById('left-div');
var box2 = document.getElementById('right-div');
var height = box1.offsetHeight;
if(box1.offsetHeight < box2.offsetHeight) height = box2.offsetHeight;
box1.style.height = box2.style.height = String(height) + 'px';
vise
Just what I was looking for, many thanks, it worked out perfectly!
perpl3x3d
A: 

What you are looking for can be found on Google if you search for "CSS equal height columns". CSS Faux Columns as mentioned by vise is one of the techniques. A roundup of equal height column techniques can be viewed here.

Salman A