Unique CSS Borders – Boring borders step aside

Lately I’ve had a lot of requests from clients for photo galleries. I decided I needed to see what css options I could come up with to keep my galleries interesting which would allow each site to look unique. Here are a few examples that I came up with.

Simply Stated

This is possibly the simplest border but one that is high on style. This one pixel solid border has 5 pixels of padding and a background color.

Sparrow

The CSS:

.plain {
	border: 1px solid #4C3C1B;
	padding: 5px;
	width: 300px;
	background-color: #EFEECB;
	}

Snapshot

If you wanted all of your images to look like Polaroid pictures, you could use this easy technique. By increasing the padding-bottom you get that “polaroid” look.

Lime

The CSS:

.snapshot {
	border: 1px solid #666666;
	padding: 10px 10px 60px 10px;
	}

Art Gallery

This technique gives each one of your images the appearance of being framed and placed in an art gallery.

moon

The CSS:

.art {
	border-style: double;
	padding: 16px;
	background-color: #DCDCED;
	}

Above and Below

Place a double border above and below your photo for a cool look!

owl

The CSS:

.ridge {
	border-top-width: 4px;
	border-bottom-width: 4px;
	border-top-style: double;
	border-bottom-style: double;
	border-top-color: #E1A60A;
	border-bottom-color: #E1A60A;
	padding: 8px 0px;
	}

Hearts

This isn’t supported in all browsers but it’s still fun! Using the border-style: dotted; and playing with the width of the image, you can get four hearts in each corner!

balloons

The CSS:

.hearts	 {
	border: 10px dotted #29C3FF;
	margin: 0;
	padding: 0;
	}

Patterned Background

Your options using a patterned background are limitless. This example also used a 1px border around the patterned background for a little more detailing.

books

The CSS:

.pattern {
	padding: 11px;
	background-image: url(squares.jpg);
	border: 1px solid #E95683;
	}

Shadow with Image

This is a similar technique as the one above using a background image. Instead of using a patterned background, I made a graphic of a shadow. To use this technique you have to know the size of your photo, create a rectangle a few pixels larger than your photo. In this example the photo is 300px wide by 199 pixels in height, I’ve created a rectangle that is 319px wide by 218 px in height. Soften the edges with your graphics software and save.

Here is the shadow image:

shadow

Add this to a div as a background and you get a pretty nice effect!

armchair

The CSS:

.shadow {
	background-image: url(shadow.jpg);
	padding: 9px;
	}

Off Balance

This example has a heavier border on the right and bottom plus a background color.

bottles

The CSS:

.right {
	width: 300px;
	padding: 0px 6px 6px 0px;
	background-color: #9FB2C1;
	border-top-width: 2px;
	border-right-width: 5px;
	border-bottom-width: 5px;
	border-left-width: 2px;
	border-style: solid;
	border-color: #082F70;
	}

Grunge

This example has a mask applied to a rectangle that I made in a graphics program.
Using the rectangle as a background image in the div creates a pretty interesting effect.

Here is the rectangle with the mask applied.

Here is the finished gallery example:

The CSS:

.grunge {
	background-image: url(laptop-graphic.jpg);
	padding: 26px 23px;
	width: 223px;
	}

Finally because this question still comes up often, I’ll show you a rounded corner border option!

Rounded Corners

There are several ways to do this example, but I will show you my favorite!

First start with a rounded corner graphic that you create in your graphics program.

Your next step is to slice it into three images.

Top

Center

Bottom

This method takes three divs. The html will look like this:

<div class=&quot;roundtop&quot;></div>

<div class=&quot;roundside&quot;>Place Your Image Here </div>

<div class=&quot;roundbottom&quot;></div>

The top and bottom div classes each have to have a width and height declared in order to see the background image.

The center div which I called “roundside” which holds the image will have “repeat-y” added.

Here is the completed result as well as css.
rounded corner
The CSS:

.roundtop {
	background-image: url(rounded-top.jpg);
	width: 315px;
	height: 10px;
	}
.roundside {
	background-image: url(rounded-sides.jpg);
	background-repeat: repeat-y;
	width: 315px;
	text-align: center;
}
.roundbottom {
	background-image: url(rounded-bottom.jpg);
	width: 315px;
	height: 10px;
}

Take some of these examples and expand upon them to create your own new css border design ideas!

45 Comments on "Unique CSS Borders – Boring borders step aside"

  1. Diane Dennis says:

    Hi Linda!

    Thank you so much!

    Just a heads up that I never received the email asking me to confirm before I could be “finalized” for the forums. I signed up hours ago so I thought I’d let you know. :)

    Thank you again for the code!

    Have a terrific evening and weekend!
    Diane

  2. blufindr says:

    In CSS3, you can also do rounded corners using pure CSS. It’s not supported by all browsers, not yet, but I’ve used it on Firefox to good effect.

  3. KevJaques says:

    Don’t forget about combining outline with border for some great ways to style borders. Of course IE7- is a pita with anything CSS wise but it should still not deter from using outline as an additional enhancement.

    Of course if wanting to keep that style across all browsers some double div workaround will be needed, however there is the argument for letting different browsers behave as they would rather than try and force the issue.

  4. Victor says:

    Great post, remember that IE requires any “FLOAT” declaration to have a “WIDTH” as well.

  5. Thanks Linda, very usefull tips and awaiting support to CSS3 in the news browsers.

  6. neville says:

    it is going to be a hard one to do

  7. Nikki says:

    Wow. These are pretty cool. I especially love the snapshot border and patterned border.

  8. Celeste says:

    Hi there,

    Sorry, i’m confused! I really like your designs and am trying to use your ridge code and implement it into my css but no matter where I put it, it doesn’t register the .ridge

    Any thoughts? Where on the css code should I put it? Thanks in advance!

    c

  9. Hi Celeste,
    You have to apply the .ridge (css class) to the image in the html. See this example below.

    Hope that helps!

  10. brindes says:

    realy.. nice .. i am going to use it.. as sson as I can…
    Thks

  11. Nice border examples!
    CSS3 has some great new features using borders but they dont work fully cross-browser (http://www.freecssmenus.co.uk/css3_border_radius_312.php). I think its wise to continue using the old fashion border method until CSS3 works in every browser.
    Many Thanks!

  12. jkjk says:

    This is your best topic yet!

    http://www.embedcn.com/

  13. lee says:

    Hi there, just became alert to your blog through Google, and found that it’s really informative. I’m going to watch out for brussels. I’ll appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers!

    http://www.nikon-battery-charger.co.uk/Digital-Camera-Battery/Nikon/Nikon-Coolpix-4500.html

  14. Harry says:

    Photoshopped Image Killer is a very useful application to get detailed information of a JPEG image as for whether it has been Photoshopped. PSKiller opens and decodes your JPEG file, then several image statistics features are analyzed to see whether some of them are abnormal compared to those of untouched images.

  15. Shirley says:

    Just wanted to say hi, I’ve been reading your site all day! Good stuff.

    http://www.giftcardcode.net

Trackbacks for this post

Got something to say? Go for it!