borderImage Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderImage

Description

The borderImage property is a shorthand property for setting

  • borderImageSource
  • borderImageSlice
  • borderImageWidth
  • borderImageOutset
  • borderImageRepeat

Property Values

Value Description
borderImageSource image URL
borderImageSlice offsets of the image-border
borderImageWidth widths of the image-border
borderImageOutset Length that the border image area can extend beyond the border box
borderImageRepeat Whether the image-border should be repeated, rounded or stretched
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: none 100% 1 0 stretch
Return Value: A String, representing the border-image property of an element
CSS VersionCSS3

Set an image as the border around a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div {/* ww w  .  ja v a 2 s .co  m*/
    background-color: lightgrey;
    border: 30px solid transparent;
    border-image: url('http://java2s.com/resources/a.png');
    border-image-slice: 30;
    border-image-width: 10px;
    border-image-outset: 0;
    border-image-repeat: round;
}
</style>
</head>
<body>

<div id="main">
  <p>This is a DIV element that uses an image as a border.</p>
</div>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("main").style.borderImageWidth = "20px 30px";
}
</script>

</body>
</html>

Related Tutorials