posted on:February 21, 2008
Custom Double Solid Borders for Images
In this brief tutorial I will show you how to create solid double borders for images and style them however you wish.
We are not going to use border-style:double; As we know these are not easy to control.
Imagine a situation where you want outer border on the image to be 3px thick and green and inner border 1px thick and yellow. How would you achieve this? And further more, how would you achieve this with no additional markup?
The Trick
What we’ll do here is use css border property for outer image border and we’ll fake the inner border using combination of background and padding properties.
First we add a border property to the image and set the values
img{ border:2px solid #72a143; }
If we set the padding to 1px and add a yellow background,
img{ border:2px solid #72a143; padding:1px; background:#ffeda5; }
the image will receive another “border” inside the real one.
That’s it! 🙂
Enjoyed the article?
Then don't miss our next one! Subscribe to our RSS feed or share it with your friends.
Share on FacebookTweet thisDeliciousStumbleUpon RedditSubscribe
Comments (20 Comments)
Sorry, the comment form is closed at this time.
Ryan
February 21, 2008
Agahmemnon
February 21, 2008
warnis
February 22, 2008
PinkPetrol
February 22, 2008
Jermayn Parker
February 22, 2008
cssglobe
February 22, 2008
Sarah
February 22, 2008
Tobias Bleckert
February 24, 2008
Marcelo
February 25, 2008
PiticStyle
February 28, 2008
emil
February 29, 2008
eXanock
February 29, 2008
Braintrove.com
February 29, 2008
gerard
February 29, 2008
ikram_zidane
March 6, 2008
Shaikh Sonny Aman
March 8, 2008
meftahul sagor
March 11, 2008
Vance Bell
April 22, 2008
Peter Anders York
June 14, 2008
monky
May 29, 2009