Internet Marketing Forum

Internet Marketing Forum


For Webmasters and Entrepreneurs
|
Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb 10, 2012, 09:54:23 AM

Login with username, password and session length

Men do less than they ought, unless they do all they can.


- Thomas Carlyle

|-   Internet Marketing Forum > Online Business Discussions > Website Design and Maintenance > Website Design
+  

CSS to limit maximum size of image

0 Members and 1 Guest are viewing this topic.
Pages: [1] Reply to Thread
Author Topic: CSS to limit maximum size of image  (Read 1700 times)
Offlinemoebius
Beginner
moebius is on a distinguished road
Joined: Jan 2008
Posts: 43


Avatar of moebius

View moebius\s Profile
Gender: MalePisces United States
notepad Mar 18, 2008, 04:26:56 AM #1
I'm currently working on a web application which (among other things) allows the user to browse a catalogue of products. Each product has an associated image, which should be shown next to the description on the screen. Images and product text are supplied by a third party.

All this is fine and dandy, until the supplied image is too large for the space allocated on the web page, when it completely screws up the text flow and pushes important information into invisibility. I have experimented with setting the height and width explicitly on the image tag, but this stretches small images and makes them look horrible.

I have little or no possibility of changing the appearance, box sizes, text flow or other on-screen stuff (it's all produced by the customer's high-power, high-price web designers), but I can add extra "invisible" JS/CSS behaviour if necessary.

What I would ideally like, is a way of showing an image at its "natural" resolution if both dimensions are smaller than a set limit, but downsizing the image to fit if it is too big. IE support is vital, Firefox important, other browsers nice to have.

Does anyone have any hints as to how I might achieve this? Is it even possible?

Many thanks in advance for any suggestions.
OfflineGalaxian
Senior Member
Galaxian is on a distinguished road
Joined: Oct 2007
Posts: 286


Avatar of Galaxian

The internet is my playground.

View Galaxian\s Profile
Gender: MaleAries United States
notepad Mar 18, 2008, 05:51:37 AM #2
There is max-width and max-height [max-width: 500px;] (thinking Mozilla only, not sure about IE7), but that is not going to keep the aspect ratio.

You would have to use JavaScript to resize it.
Offlinesharifweb
 left the building  
Beginner
sharifweb is on a distinguished road
Joined: Jun 2009
Posts: 12


anonymous avatar

View sharifweb\s Profile
notepad Jun 20, 2009, 12:38:52 PM #3
thanks
Offlinesharifweb
 left the building  
Beginner
sharifweb is on a distinguished road
Joined: Jun 2009
Posts: 12


anonymous avatar

View sharifweb\s Profile
notepad Jun 20, 2009, 12:43:23 PM #4
nice....

Thanks
Offlinemartinmort
Beginner
martinmort is on a distinguished road
Joined: Oct 2009
Posts: 14


anonymous avatar

View martinmort\s Profile
notepad Oct 15, 2009, 04:32:36 PM #5
Thanks for the info

Offlineraja77
Beginner
raja77 is on a distinguished road
Joined: Sep 2011
Posts: 30


anonymous avatar

View raja77\s ProfileWWW
United Kingdom
notepad Oct 05, 2011, 05:43:58 PM #6
Use css poperty min-width:600px; max-width:700px;  you can put whatever dimention you want

Summer Savings! $7.49 .com domains at GoDaddy.com!
Pages: [1] Reply to Thread


Code4Gold Internet Marketing Forum © 2006-2011 Resdaz Media LLC - All Rights Reserved
Forum Software Powered by SMF - © 2001-2008, Lewis Media. All Rights Reserved.