Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use an image for a border in CSS

Tags:

css

image

border

I want to set the border of a table to be "1px solid black" except on the bottom, where I want to use an image which provides a pointer into the link - as a visual aid.

Is it possible to set an image as the bottom border when the other borders are regular css.

like image 897
Ankur Avatar asked Jul 13 '09 08:07

Ankur


People also ask

How do you put a border around an image in CSS?

CSS Syntaxborder-image-width: number|%|auto|initial|inherit; Note: The border-image-width property can take from one to four values (top, right, bottom, and left sides). If the fourth value is omitted, it is the same as the second. If the third one is also omitted, it is the same as the first.

How do I use an image in CSS?

To add images to a page, we use the <img> inline element. The <img> element is a self-containing, or empty, element, which means that it doesn't wrap any other content and it exists as a single tag. For the <img> element to work, a src attribute and value must be included to specify the source of the image.


2 Answers

Try putting the table inside <div class="myTableContainer"></div> and then:

.myTableContainer{
  padding-bottom: 1px;
  background: url(myBorderImage.png) bottom left;
}

This should work well across all browsers.

like image 100
warpech Avatar answered Oct 02 '22 02:10

warpech


CSS3 has added support for border-image. You can find more information at http://www.w3.org/TR/css3-background/#border-images. At this point (early 2012), it's probably not safe to use due to lack of support in all versions of IE. To track when it is safe to use you can visit http://caniuse.com/#search=border-image. One way to simulate the border-image style is to use a positioned background-image. For example, to simulate a top border:

div
{
  background-image: url('topBorder.gif');
  background-position: top;
  background-repeat: repeat-x;
}
like image 24
Brian Hasden Avatar answered Oct 02 '22 03:10

Brian Hasden