1

My problem is more or less identical to this question, but with the slight difference that I need to vertically resize it.

What I mean is; according to the information supplied in the article I linked to, the DIV will resize while keeping the aspect ratio if you stretch/contract the browser width, but not if you make the browser window taller/shorter (ie, its height) - I wonder if it's possible to make this work in a CSS-only environment.

TYIA.

Community
  • 1
  • 1
kunambi
  • 756
  • 1
  • 10
  • 25

2 Answers2

1

No, this isn't possible.

The closest thing that is possible is described in the answer to this question: Make an element's width relative to its height?

...however, that requires introducing an img tag into the source.

Community
  • 1
  • 1
Brilliand
  • 13,404
  • 6
  • 46
  • 58
1

If you are dealing with just an image, then setting its width to 100% and removing its height will keep its aspect rate, but obviously will also degrade its quality at great stretchings.

Like this:

img {
    width: 100%;
    height: auto;
}
jackJoe
  • 11,078
  • 8
  • 49
  • 64
  • 1
    I'm not working with an image, which you can see by following the link I supplied. What I want is an element (eg, a DIV-element) to work like an image when scaling its height. – kunambi Oct 21 '11 at 12:53