HTML DOM Style clip properties
Definition and Usage
clip property sets or returns the visible part of the positioning element.
grammar
Setting clip properties:
Object.style.clip="auto|rect(top right bottom left)|inherit"
Back clip properties:
Object.style.clip
值 | 描述 |
---|---|
auto | 默认。元素没有剪辑。 |
rect(top right bottom left) | 剪辑的形状由四个坐标定义。 |
inherit | clip 属性的值从父元素继承。 |
Browser Support
All major browsers support clip property.
Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".
Examples
Examples
The clip image for the specified shape:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
img{
position:absolute;
top:100px;
}
</style>
<script>
function clipImage(){
document.getElementById("img1").style.clip="rect(0px 75px 75px 0px)";
}
function clearClip(){
document.getElementById("img1").style.clip="auto";
}
</script>
</head>
<body>
<img id="img1" src="w3javascript.gif" width="100" height="132">
<input type="button" onclick=clipImage() value="裁剪图片">
<input type="button" onclick=clearClip() value="不裁剪图片">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<style type="text/css">
img{
position:absolute;
top:100px;
}
</style>
<script>
function clipImage(){
document.getElementById("img1").style.clip="rect(0px 75px 75px 0px)";
}
function clearClip(){
document.getElementById("img1").style.clip="auto";
}
</script>
</head>
<body>
<img id="img1" src="w3javascript.gif" width="100" height="132">
<input type="button" onclick=clipImage() value="裁剪图片">
<input type="button" onclick=clearClip() value="不裁剪图片">
</body>
</html>
try it"
Style Objects