PDA

View Full Version : Custom Borders in CSS



Abus
December 5th, 2006, 03:13 PM
I am trying to give a background-image to a border but it does not work. Is it possible to give a background-image to a border?

fasterthanlight™
December 5th, 2006, 03:17 PM
no

create a div that mimmics your border in position and size, and give that a background image.

MTsoul
December 6th, 2006, 04:35 PM
Or you can add the border directly to the image with Photoshop or something.

Abus
December 7th, 2006, 09:24 PM
Or you can add the border directly to the image with Photoshop or something.

I can make a background image with borders, thanks for the idea

MTsoul
December 7th, 2006, 10:41 PM
No problem.

tommythewolfboy
December 11th, 2006, 11:17 AM
I would apply the image as a background to a container div, and then assign borders to the div using CSS, rather than going into photoshop. That way, ifyou want to change/remove the border, you just need to edit the CSS, rather than recreate the image. Gives you more flexibility, that's all. Give me a shout if you want an e.g. of the code.

fasterthanlight™
December 11th, 2006, 11:50 AM
css borders will only work if you want simple borders.. if you want something ornamental you're going to have to do some CSS trickery

tommythewolfboy
December 11th, 2006, 01:57 PM
css borders will only work if you want simple borders.. if you want something ornamental you're going to have to do some CSS trickery

Ah yes, I've re-read the initial post and see what you mean. That'll teach me for meddling ;)

fasterthanlight™
December 11th, 2006, 02:02 PM
hehe

Abus
December 12th, 2006, 08:13 AM
I need something more than normal borders, but thx anyway :beer:

fabiopb
December 12th, 2006, 09:22 AM
create two divs.

1 is the "container" div which will have the image you want as the border, say 300 x 300 pixels. and you set that div to display that image. this div will be borderless.

2 is the other div which will be inside the container div (1), which will have a background color matching your entire web page's background color, borderless, which will be have padding as thick as you want your image border to be, so that the space between the two divs will reveal the image behind the second div.

so to put it simply, it is almost as if you are subtracting visibility from one div using another div. if you cant get round to it, let me know, and when i get back home from my trip, i'll show you a small example.