CSS Borders – Part II

CSS Borders – Part II

CSS Borders continued! More borders examples for inspiration. I encourage you to play around and make these examples your own!

By Linda Chadbourne on July 6th, 2009 in Articles | Print This Article

Learn how to use CSS and a few graphics to dress up images.  Hopefully this article will inspire you and give you new techniques.  This is a follow-up to my original article “Unique CSS Borders – Boring Borders Stop Aside” which you can see here.

Double Border

This easy to create double border is so easy.  This is a double border with a background color added.  By adding 2 pixels of padding to the image you get a nice inner line which adds another dimension of design.  You will get a different look depending on the browser used but the borders still look nice and your viewers will not know.

sheep2 CSS Borders   Part II

The CSS:

.double {
	border: 20px double #2B3500;
	background-color: #D6E67B;
	padding: 2px;
}

Art Deco

This is another very easy border. By using the border class: dash and a background color you get this very nice art deco design. I’ve also added 2 pixels of padding to the image in order to give a little more detail.

burger CSS Borders   Part II

The CSS:

.art-deco {
	border: 7px dashed #73BFBA;
	padding: 2px;
	background-color: #000;
}

Two Tone

This is a bit reminiscent of the beveled edges of the early days. One suggestion that I have is to keep the border colors close so you don’t end up getting that retro look that makes us cringe.

pelicans CSS Borders   Part II

The CSS:

.two-tone {
	border-top: #DBEEF2 10px solid;
	border-right: #B7DDE6 10px solid;
	border-bottom: #B7DDE6 10px solid;
	border-left: #DBEEF2 10px solid;
	padding: 2px;
}

Decorative X

By creating a graphic and using it as a background image, you can get a variety of unique looks.
For this example I created a graphic that is 10 x 10 pixel and applied a black background. I created the diagonal lines in gray to create an “X” like this.  x By adding padding of 10 pixels (same as the graphic size) you get a nice effect.  You can experiment with circles, triangles or bow tie shapes.

cake CSS Borders   Part II

The CSS:

.x-back{
	padding: 10px;
	background-image: url(x.jpg);
	border: 1px solid #000;
}

Nested Divs

This example uses two nested divs (inner and outer) to create a more interesting border. I found the background patterns at DinPattern. You’ll see that the inner and the outer divs both have an image as a repeating background and also a solid border.  Be creative with background patterns or textures to make some really different looks.

car CSS Borders   Part II

The HTML:

    <div class="outer">
	   <div class="inner">
    	<img src="car.jpg" width="382" height="303" alt="" />
     </div> 	<!--end inner div -->
   </div> <!--end outer div -->

The CSS:

.inner {
	width: 300px;
	padding: 10px;
	background-image: url(tread.gif);
	background-repeat: repeat;
	border: 1px solid #006;
}
.outer {
	padding: 20px;
	width: 330px;
	background-image: url(haunted.gif);
	background-repeat: repeat;
	border: 2px solid #666;
}

Have questions or ideas for other borders, post in the CSS Forum!

Did you like it?

Help us spread the word!

About The Author

Linda Chadbourne
Linda Chadbourne
Linda Chadbourne has been a web designer since 2001. A large portion of her day also involves graphic and logo design for Cozy Penguin Web Studio which she owns and operates. Linda is also one of the co-founders of The Web Squeeze which is a Web Design and Development Help Forum. In her free time she is an avid family person, horseback rider and reader.

Comments

  1. Gravatar Icon
    Brant said :

    Nice code for individuals struggling with borders.

Do you have something to say?

Live Comment Preview