Style clipPropiedad
Objeto Style
Definición y uso
La propiedad clip establece o devuelve la parte visible de un elemento posicionado.
Sintaxis
Establecer la propiedad clip:
Object.style.clip="auto|rect(top right bottom left)|inherit"
Devolver la propiedad clip:
Object.style.clip
| Valor | Descripción |
|---|---|
| auto | Predeterminado. El elemento no está recortado. |
| rect(top right bottom left) | La forma del recorte se define mediante cuatro coordenadas. |
| inherit | El valor de la propiedad clip se hereda del elemento padre. |
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad clip.
Nota:IE7 y versiones anteriores no admiten el valor "inherit". IE8 solo admite "inherit" si se especifica !DOCTYPE. IE9 admite "inherit".
Ejemplo
Ejemplo
Recortar la imagen en la forma especificada:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.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.html" width="100" height="132">
<input type="button" onclick=clipImage() value="Recortar imagen">
<input type="button" onclick=clearClip() value="No recortar imagen">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.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.html" width="100" height="132">
<input type="button" onclick=clipImage() value="Recortar imagen">
<input type="button" onclick=clearClip() value="No recortar imagen">
</body>
</html>
Pruébalo »
Objeto Style Otras extensiones