Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

creating a border image

I am trying to create a border image for a wordpress site but the border is not displaying.

I have selected a random photo off of google to try it and it doesn't work.

Are there certain dimensions needed for it to display? Or what am I missing?

the image file has been placed in the same directory as the stylesheet

4 Answers

I can create borders but having trouble with border-image

code im using is border-image: url(imagename.png);

e.g.

<style>
div {
  border-image: url('wood-border.png');
  width: 40%;
  border: 2px solid black;
}
</style>
<div>
this is content
</div>

the solid black border appears, but the image border doesn't. Not sure if there is a problem with dimensions of image or I am missing something.

Hi David,

I just tried it out, and the styles border and border-image are over-writing each other. Whichever style comes last is the one that will be visible.

Can you please show me any live markup or code what you're trying ? May be in codepen.io ?

Though this is basic code which you can use to give image a border :

img {
    border: 5px solid red;
}

Well there're different things you need to check , like you've given a border width with color and style.

And border image is big enough or stretched so that you can see, here's the CSS syntax for border image :

border-image: source slice width outset repeat|initial|inherit;

Though for reference you can check this out :

http://www.w3schools.com/cssref/css3_pr_border-image.asp

Yeah I had already gone through that page. Problem is nothing is loading. It's probably something simple I am missing.

EDIT:

Ah thankyou Robert! I moved the border rule above the border image rule and it now works.

As Robert said, use border-image property after the border property as border property is overwriting the border-image.