mattastic — 2011-05-11T06:14:33-04:00 — #1
I have a number of photographs on my site, I'd like to surround them all with the attached graphic, like a photo frame.
The photos are different sizes, so it would be good if the graphics were expandable.. Could I use a techique similar to spiffy corners, or is there another way I can do this using css?
paulob — 2011-05-11T06:31:58-04:00 — #2
You could do it in the usual slicing way but it may be awkward to match the edges as they are not uniform.
I wonder whether it may be easier to use a foreground image for the frame and make it stretch to fit the image. The image is basically black so the loss of quality shouldn't really be an issue.
I'll have to try and make a demo and see if it will work
ralphm — 2011-05-11T06:36:13-04:00 — #3
The trick (or at least one way to do it) is to break that background image into three sections—a top, a middle section that can repeat, and a bottom. If the middle section can repeat seamlessly, then that container can expand to fit any photo size.
So, assuming you take that approach, create three divs: one that holds the top part of the background; one that has the middle part of the background as a repeating background image, and which also contains the actual photo; and then a bottom div that holds the bottom part of the background image.
Edit: sorry, posted over the top of Paul.
mattastic — 2011-05-11T06:47:27-04:00 — #4
That sounds ideal, I'm not too fussed about the quality of the image like you say. Thankyou
mattastic — 2011-05-11T07:30:46-04:00 — #5
So far I have this:
Its close, but I'd like the background image to scale to the size of the div. Not to bothered about quality of the background image, any pixelation would add to the effect anyway.
Any help much appreciated.
paulob — 2011-05-11T07:54:20-04:00 — #6
This is how I'd do it.
The background will fit any image as required. It's pretty straight forward (apart from ie6 and 7) and just scales the image to fit the div with absolute positioning.
(You could use percentage padding if you want the frame border width to get smaller or thicker depending on image size.)
paulob — 2011-05-12T05:38:25-04:00 — #7
Did you manage to get this working or do you need some more help
mattastic — 2011-05-12T05:51:26-04:00 — #8
Thanks very much I've got it working now.
Many thanks again your a star!