PDA

View Full Version : stating size of images in css


Andromeda
05-06-2007, 02:24 AM
Still dabbling in css and wondered if it would be possible to state the size of images in css rather than in html? e.g:

css
img .thumbnail {width:150px; height:100px;}

html
<img class="thumbnail" src="images/jupiter.jpg">


The above code won't work for me but I wondered if there was something I wasn't doing right or whether it can't be done.

Andromeda
05-06-2007, 03:04 AM
ok. Just answered my own question. It does work. I took the space out of
img .thumbnail

chriskq
05-07-2007, 09:16 AM
lol - u dont even need to specify a height and width for an image if you using doc type xhtml

even if u added it inline style eg: width="500" (well thats not an inline style now is it). This would cause your page not to validate as its for html 4.0 doctype.

of course if your adding the image onto a background, then yes width and height is needed.

chriskq
05-07-2007, 09:18 AM
i hope ur not altering the actual size of the image with css... much better to save out the image in the size you need, unless ur doing something trickey like this:

http://cssplay.co.uk/menu/image_magnifier.html

Andromeda
05-07-2007, 09:42 AM
Cool!!

But no, I'm not up to the tricky stuff yet and I'm not intending on sizing / re-sizing images the way I suggested either. I was just reading up on css and wondered if it could be done.