Create a Double Border Image Effect Using CSS
CSS doesn't allow for too many cross-browser compatible effects. Webkit has added some webkit- CSS effects, but I'm talking about a more toned-down, subtle effect. Did you know you can add a double-border effect to your images using basic, cross-browser CSS? Let me show you how.
The CSS
img.double-border { border:1px solid #ccc; padding:2px; background:#eee; }
You can give your image a background-color property and add padding to the image to create the double border effect. It's a simple but effective design trick. You could enhance an image's appearance during the hover effect using this "double border."
What would you use this for?
![How I Stopped WordPress Comment Spam]()
I love almost every part of being a tech blogger: learning, preaching, bantering, researching. The one part about blogging that I absolutely loathe: dealing with SPAM comments. For the past two years, my blog has registered 8,000+ SPAM comments per day. PER DAY. Bloating my database...
![Designing for Simplicity]()
Before we get started, it's worth me spending a brief moment introducing myself to you. My name is Mark (or @integralist if Twitter happens to be your communication tool of choice) and I currently work for BBC News in London England as a principal engineer/tech...
![Editable Content Using MooTools 1.2, PHP, and MySQL]()
Everybody and their aerobics instructor wants to be able to edit their own website these days. And why wouldn't they? I mean, they have a $500 budget, no HTML/CSS experience, and extraordinary expectations. Enough ranting though. Having a website that allows for...
![Introducing MooTools Templated]()
One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating:
new Element Madness
The first way to create UI-driven...
Nice effect, David! Also I like the MooTools logo on Sam’s hat.
Yes, this is a nice way of acomplishing that effect, i use it very often just with a larger padding. On one gallery i used white background, grayish border, 5px padding and then an aditional drop shadow effect (image). So the final result turns out to be perfect.
I can think of a couple of browsers that do not support this and I ain’t gonna say they are both made by MS ;)
Can you be more specific with that ?
I tested my way in most of the browsers (IE6, 7, FF2, 3, Opera, Safari etc.) and works like a charm. Only problem i can think of (would need to test that) is maybe the default img display:inline;
I know this tip by css-globe 6 months ago.
Use a black border and white background to have a nice effect.
Very slick!
That is pretty nice. Never would have thought of using background and padding to create the inner grey “double” border.
Creare un bordo doppio per un immagine
http://moukadesign.altervista.org/css-creare-un-bordo-doppio-per-un-immagine/
@Elmas — it’s all about the right !DCOTYPE. If you manage to run IE 6 in standads mode — you will see the padding. If you do not manage, however, you will run the page in Quirks mode and not see the padding.
The easiest way to trigger Quirks mode is to add a XML prologue or add anything but white space before the DOCTYPE e.g. comment ;)
See at http://en.wikipedia.org/wiki/Quirks_mode for quick info.
Really cool, simple, elegant idea. Nice work.
You can also use
outline: 1px solid #000;
to achieve the same effect.
// Tim
Outline is not cross-browser ;)
Thanks for sharing this
He intentado crearlo en la web http://www.eyaculacion-precoz.info pero no he podido, me puedes ayudar?
Um,
border-style: double;
You are the man. This is exactly what I needed. :) I’m trying to replace a heavy WordPress/plug-in setup with a custom display site, and this was the one thing I needed to replicate the behavior of my gallery plug-in.
Thanks!
I love your stuff, first of all. I’ve followed for a while. I came by this in a google search though and it doesn’t really solve the problem I was looking to solve at least. I mean it’s clever and all but I can’t use this in my current situation. For example, it’s not really a double border its just colored padding… I already have padding on the element I’m trying to style so this doesn’t work for anything unless you aren’t going to use padding or unless you use a workaround.
The CSS
img.double-border { border:1px solid #ccc; padding:2px; background:#eee; }
Copy Codeimg.double-border { border:1px solid #ccc; padding:2px; background:#eee; }
much better than inline styling
In sane browsers and IE >= 8, you can get a triple border effect by using outline in addition to this trick.
nice, love to apply that on my sites. awesome sharing!
Wonderfull!!! :D