las propiedades del clip de estilo HTML DOM
Definición y Uso
clip de conjuntos de propiedades o devuelve la parte visible del elemento de posicionamiento.
gramática
Configuración de las propiedades del clip:
Object.style.clip="auto|rect(top right bottom left)|inherit"
las propiedades del clip para la espalda:
Object.style.clip
值 | 描述 |
---|---|
auto | 默认。元素没有剪辑。 |
rect(top right bottom left) | 剪辑的形状由四个坐标定义。 |
inherit | clip 属性的值从父元素继承。 |
Soporte para el navegador
Todos los principales navegadores soportan propiedad de clip.
Nota: Internet Explorer 7 y versiones anteriores no son compatibles con el valor "heredar".IE8 sólo proporciona! DOCTYPE apoyado "hereda". apoyo IE9 "hereda".
Ejemplos
Ejemplos
La imagen del clip de la forma especificada:
<!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>
Trate »
Objetos de estilo