Click here to get back home

fixed image size

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
fixed image size finecur 02-12-2007
`--> Re: fixed image size Jukka K. Korpel...02-13-2007
Posted by finecur on February 12, 2007, 1:53 pm
Please log in for more thread options


I have a <img scr="mypic.jpg"> in my html. I would like to display the
image by width=200 if the image width is larger than 200. I also would
like to display the image by its real width if the image width is
smaller than 200. How can I do it?

Thanks,

qq


Posted by Ben C on February 12, 2007, 2:34 pm
Please log in for more thread options


> I have a <img scr="mypic.jpg"> in my html. I would like to display the
> image by width=200 if the image width is larger than 200. I also would
> like to display the image by its real width if the image width is
> smaller than 200. How can I do it?

img { max-width: 200px; }

Posted by Bergamot on February 12, 2007, 3:04 pm
Please log in for more thread options


Ben C wrote:
>
> img { max-width: 200px; }

If you're going to do this, you might want to omit setting the height
attribute in the img element, so it will scale correctly. Otherwise,
you'll get a distorted image.

--
Berg

Posted by Jukka K. Korpela on February 13, 2007, 12:47 am
Please log in for more thread options


Scripsit finecur:

> I have a <img scr="mypic.jpg"> in my html.

You should fix the markup then (at least by adding an alt attribute).

> I would like to display the
> image by width=200 if the image width is larger than 200. I also would
> like to display the image by its real width if the image width is
> smaller than 200. How can I do it?

Although you can do that as others have replied, using the max-width
propertym though not for IE 6 or older, it's almost always a wrong idea to
do such things via markup or style sheets. The image should be converted to
a suitable size on the server or before it is uploaded onto the server, for
two basic reasons:
1) More efficient - it's foolish to transfer a large image and then have it
shrinked, losing much of its quality that required so many bytes.
2) Better quality - browsers aren't really good image processing software.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Similar ThreadsPosted
How to keep the table a fixed size December 8, 2004, 8:59 pm
Optimized table with fixed size cells? February 4, 2007, 5:17 pm
size attribute of input element: characters not fixed width? January 30, 2005, 7:26 pm
fixed background image w/css problem September 27, 2004, 9:29 pm
Display larger size image August 6, 2004, 11:56 pm
Restricting inline image size March 29, 2005, 6:56 pm
Re: Restricting inline image size March 29, 2005, 9:24 pm
Re: Restricting inline image size March 30, 2005, 2:07 am
client-side image size changing question June 22, 2005, 6:26 am
Firefox - Prevent TextField size change when user changes font size? October 3, 2006, 6:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap