Sent by Adam Kuehn on 6 December 2004 21:09
At 1:48 PM -0600 12/6/04, Pringle, Ron wrote:
> > Can I use a div to force a image to fit on a screen?
>
>Yes, you can assign height and width values of 100% to it and it will scale
>to fit the screen (or its maximum dimensions, whichever comes first).
>
>I do not believe there is a way to proportionally scale the image through
>the use of CSS.
You can proportionally scale an image in CSS by using relative units
in the correct ratio (em, ex, for example). What you can't do with
CSS alone is both scale proportionally and scale to fit an arbitrary
viewport. You could try to make some assumptions about the viewport
and go from there, but there is no way without scripting to make the
image fit exactly and without scrolling. Even so, traditional gifs
and jpegs may tend to look a bit odd at certain non-native sizes,
even if those sizes are relative.
You can do pretty much what you want with CSS and client-side
scripting, though. The script gets the viewport dimensions and then
writes out the appropriate CSS (usually in pixels). The details
would be a question for a Javascript or general web design list,
though. A disadvantage of such an approach is that is would not work
if a user turned off javascript. If you have a reasonable default
size applied, though, that may be what you are looking for.
Good luck,
--
-Adam Kuehn
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/