Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

css image resize - absolute dimensions

Status
Not open for further replies.
Jul 28, 2005
358
FR
Hi,

I hope someone can help as I am well and truly stuck.

I need to resize images using css but can't get it to work. The images are displayed using an asp tag and I need to resize them down to 97 x 76 pixels. At the moment they are 120 x 90 pixels.

Does anyone know of a way to do this.

Richard
 
If you give the image an id (ask in the ASp forum if you do not know how to do this, but here's how to do it using 'real' HTML):

Code:
<img id="someId" src="whatever.gif" />

then in your CSS, you can use:

Code:
img#someId {
   width: 97px;
   height: 76px;
}

But better still, just deliver the correct widths to the page for the img:

Code:
<img id="someId" src="whatever.gif" width="97" height="76" />

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Fraid it didn't help,

The script that provides the picture calls it as <%picture%> and as the script which is php (sorry, my mistake it just calls using the tag which I now presume isn't asp at all but a php call) is encoded I can't get to it We may have to resize all the images manually and make sure that all the new ones are the right size. I can't see any other way around it though.

Richard
 
You shouldn't really rely on HTML to resize your images - browsers do a worse job of it than proper graphics programs do, and it's wasteful of time and bandwidth to send a full-size image down the wire only to be squashed to a smaller size at the other end. That said, there won't be a huge difference in file size between a 120x90 image and a 90x76 one.

If you've got a lot of images to resize, use a tool to do it automatically. There seem to be plenty out there:
-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Would if I could but unforyunately it's one of those scripts where the php is encoded using ioncube so I can't getinto the php itself. Otherwise it would be a breeze!!!

Richard
 
What you could do is use a dependancy selector. For instance, you put all your images inside a div that you give an id for instance, <div id="imageholder">, then add slightly modified Dan's code into the stylesheet:
Code:
#imageholder img {
   width: 97px;
   height: 76px;
}
 
Try wrapping the asp call in a div.


Code:
<div class="resizedImage">
<%picture%>
</div>


Then use CSS like so

Code:
.resizedImage img {
 width:97px;
 height:79px;
}

Might work.

Better still would be to wither use different images or modify the code to generate thumbnails/resize the images.

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
Yep, Foamcow wins the prize (the right to look smug!!).

Thanks loads, it works a treat!!

Rich
 
I thought he has some kind of gallery and will put all, not just one by one, pictures inside that container. But I guess using a class is a safer approach, though ids are higher on the preferential list if that is ever needed. To be entirely correct, one might consider stuffing images in span rather than div, since span, just like img, is an inline element. :)
 
Replaced elements are elements that switch the tag you put on the page for some other entity. Elements such as img, input, textarea, select, and object are all replaced elements, as what you see in the source is not what you see on screen. See here for more information:


Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
It's actually just an image for a property rental script. When a list of properties is displayed it displays one image of each property. I have to make the css from a photoshop image keeping as close to possible to the design. That's why I needed the image resizing.

Thanks all that helped, you never know I might be back. Fiorefox and IE are awful for displaying the same!!

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top