View Full Version : Resolved Tile Background

05-13-2011, 01:28 AM
I am attempting to tile my background image. The problem I am having is that the img is too large. I want to modify it's size without having to consult graphic design every time. I was thinking of possibly containing it withing a div element (which I CAN control the size; and then control the image size that way) but I am pretty sure there is no way to use a div as a background-image. Also this is via CSS.

If anyone knows of a "trick" to modify the size of a background image I would love the help!

05-13-2011, 02:11 AM
A div will stretch to the size of the image. You cant "control" an image size with a div. You can resize an image in an image editor. You can also set a size to an image using css, but not a background image.

05-13-2011, 02:58 AM
you can use a div to contain an image... you can set a div size (100px X 100px) and then set the image within it and assign its size to 100% of the containing element. I guess you could also do this by assigning img size, but i like to think of things as blocks on my page... i guess though that is a "no" you can't do some trick to manipulate the img to the size u want?

05-13-2011, 03:06 AM
Dont confuse "containing" an image with "controlling" an image size. A div will not control an image. If you set a height and width to a div, then place an image inside that div thats larger than the div size, it will break your box model.

There maybe ways to automatically resize images using js or even a server side. I think Coldfusion has a cfimage tag with some sizing attributes, but I think its best to size your images before using them in your code. That way you dont run the risk of distortion, nor do you run the risk of longer page load times and way more code than you need.

05-13-2011, 03:48 AM