473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

fixed image size

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

Feb 12 '07 #1
3 21633
On 2007-02-12, finecur <fi*****@yahoo.comwrote:
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; }
Feb 12 '07 #2
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
Feb 12 '07 #3
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/

Feb 13 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
98
by: Pamel | last post by:
I know this must have been asked elsewhere, but I cannot find it. There is a piece of text on my web page that I don't want browsers to resize. IE won't resize it if I specify the size in px, but...
2
by: Danny | last post by:
Hello I am trying to keep a table or row a fixed size. I have a javascript that assigns different images to the SRC of the main image, but the table will resize whne there is a smaller height...
2
by: neuneudr | last post by:
Hi everybody, I'm scratching my head with a CSS problem. I want to have the following (the two pics have these size for a good reason, the whole point of the page is basically to show these...
7
by: finecur | last post by:
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...
1
lotus18
by: lotus18 | last post by:
Hello I'm using vb6 and CR 11. How to manage Image in CR? I inserted an image in the Report Header (ReportHeader Section1), then when I run it, the image size is not the same as during the...
2
by: satya.komatineni | last post by:
I have struggling with this for 2 days. I searched far and wide in google and msdn etc. No luck. Hope one of you may have seen this. I am seeing this in ie6 and ie7 What I want **************...
4
by: crazychrisy54 | last post by:
Hi there, I am new to JavaScript and wonder if it could be used to solve my problem, any help would be much appreciated! I have a html web page which contains a table on the left hand side and...
0
by: RubbedLung | last post by:
http://www.hometeamproperties.net/Forms/PVA/LPV.htm As you can see its a valid page but now the bottom right rounded corner is gone, and there are entire blocks of color missing from the interior...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.