views:

118

answers:

1

I used the same software used here http://us.gn.bartal.org/ to create a fixed width/height treemap in HTML + CSS.

I would like to make it elastic by having a JavaScript function to convert all pixels absolute positions and sizes to percentages.

How would you suggest to proceed? Is there some jQuery/Prototype/Dojo magic that I can exploit?

A: 

Your basic process would be something like this:

  • Identify the elements that need resizing
  • Write some JQuery to find the sizes of those elements
  • Calculate the percentages (or other values)
  • Make the adjustments
  • Subscribe to all relevant resize events
  • Recalculate the sizes on each resize event
John Fisher
I already wrote a solution which work pretty much like this. However, I would prefer to convert them in actual percentage-size elements, so that they will naturally adapt to resizing.
phretor
@phretor: Then, all you need to do is step 3 from my answer.
John Fisher
Thank you John. I hope height: X%; is cross-browser :)
phretor