HTML DOM clip Property
Complete Style Object Reference
Definition and Usage
The clip property sets the shape of an element.
What happens if an image is larger than the element it goes inside? - The
"clip" property lets you specify the dimensions of an element that should be
visible, and the element is clipped into this shape, and displayed.
Syntax
Object.style.clip=rect(top,right,bottom,left)|auto
|
Possible Values
Value |
Description |
rect(top,right,bottom,left) |
Sets the shape of the element |
auto |
The browser sets the shape of the element |
Tips and Notes
Note: This property cannot be used for elements with an "overflow"
property set to "visible".
Example
The following example clips an image into a specified shape:
<html>
<head>
<style type="text/css">
img
{
position:absolute;
top:100px;
}
</style>
<script type="text/javascript">
function clipImage()
{
document.getElementById("img1").style.clip="rect(0px,50px,50px,0px)";
}
</script>
</head>
<body>
<img id="img1" border="0" src="logocss.gif" width="95" height="84" />
<input type="button" onclick=clipImage() value="Clip image" />
</body>
</html>
|
Try-It-Yourself Demos
Clip -
Clip an image into a specified shape
Complete Style Object Reference
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|