backgroundClip Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:backgroundClip

Description

The backgroundClip property sets or gets the background region.

Property Values

Value Description
border-box Default value. background is clipped to the border box
padding-box background is clipped to the padding box
content-box background is clipped to the content box
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: border-box
Return Value: A String, representing the background-clip property of an element
CSS VersionCSS3

Set the painting area of the background:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {// w  ww .  j a  va  2s.c  o  m
    width: 300px;
    height: 300px;
    padding: 50px;
    background-color: coral;
    background-clip: border-box;
    color: white;
    border: 5px dotted lightgrey;
}
</style>
</head>
<body>

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

<div id="myDIV">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</div>

<script>
function myFunction() {
    document.getElementById("myDIV").style.backgroundClip = "content-box";
}
</script>

</body>
</html>

Related Tutorials