Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imitating the IMG tag

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
An IMG always retains proportion when resized.

Example: <img src="" height="100%">

When the user resizes the window containing above image, the height/width do not distort.

How can any element that may contain children, be made to behave the same way?

----------
I'm willing to trade custom scripts for... [see profile]
 

I think you'd have to use JS for this one... Work out the aspect ratio for every element you want to keep at the correct proportions, and on resize, set the width (or height) depending on the height (or width).

Having said that, there's probably a really easy way that I haven't thought of ;o)

Hope this helps,
Dan
 
That does work, but it's a little messy.

IE: Choppy animation
NS: Resizes after resize / flickers

Is there a way to hide it at the start of a resize?

----------
I'm willing to trade custom scripts for... [see profile]
 
The other problem you'll run into is image distortion and pixelation. You can probably get by OK with a 10%-15% change with too much loss of quality but after that, I doubt that you like the final appearance.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top