Latest web development tutorials

HTML DOM 스타일 클립 속성

스타일 객체 참조 스타일 개체

정의 및 사용

속성 집합을 클립이나 위치 결정 부재의 가시 부분을 반환한다.

문법

클립 속성 설정 :

Object.style.clip="auto|rect(top right bottom left)|inherit"

다시 클립 속성 :

Object.style.clip

描述
auto 默认。元素没有剪辑。
rect(top right bottom left) 剪辑的形状由四个坐标定义。
inherit clip 属性的值从父元素继承。


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 클립 속성을 지원합니다.

참고 : IE7 및 이전 버전은 "상속"값을 지원하지 않습니다.IE8은 "상속"지원!의 DOCTYPE을 제공합니다. IE9 지원 "상속".


지정된 모양의 클립 이미지 :

<!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>

»시도


스타일 객체 참조 스타일 개체