Change the size of a background image to fit the DIV element

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Change the size of a background image to fit the DIV element

Post by Chris Corbyn »

Hi,

I've designed a simple background image to use as a backing for all my chunks of text etc by putting text in a DIV element with a backround image.

I was wondering if, since I will use the image over and over in various sized (though similarly sized) DIV elements there is a way to add some height and width attributes to the image?
The code I'm using at present is:

Code: Select all

<div align=center style="background-image: url(backing.gif); height: 400px; width: 330px;">
Even better if the image would dynamically change size onload.

Thanks :-)
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

d11wtq,

I don't think so man...i think however that you should make the image a certin size aspect.

I do things like that all the time...i make my background images in such a way that no matter what size it is it conforms and doesnt look as though it is repeating even doe it does!

Kendall
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yeah i see how you mean.

My all my image is just one big solid block of color in a rectagular shape with smooth rounded corners. I need the corners to only appear at corners so I could perhaps chop my corners out and stick everything in a little table with the corner cells containing the bit for the corners and all else containing just a background color which is identical to the image color. My page would load faster too I guess. Is that the normal way to do things like that?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yeah I've sorted it out by chopping up and using tables. Looks sweet
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

kENDALL,

YEAH THAT WORKS TOO LOL
Post Reply