JavaScript

[DOM_Style] JS - clip 속성 - 이미지 일부만 노출 (= 이미지 자르기 = clip속성 = 클립속성)

목차

  1. clip 예제 - clip 속성값 설정
  2. clip 정의
  3. clip 구문
  4. clip 예제 - clip 속성값 반환

 

clip 예제 - clip 속성값 설정

 

<style>

img {position: absolute; top: 50px; width:185px; height:39px;}

</style>


<img id="hz" src="https://i.imgur.com/WfW5mBC.png">


<button type="button" onclick="clipRect()">Clip image</button>

<button type="button" onclick="clipAuto()">Unclip image</button>


<script>

function clipRect() {

  document.getElementById("hz").style.clip = "rect(0px 172px 39px 33px)";

}


function clipAuto() {

  document.getElementById("hz").style.clip = "auto";

}

</script>

 

결과보기

 

clip 정의

 

CSS clip 속성 설정/반환.

 

 

clip 구문

 

clip 속성의 속성값 반환

object.style.clip


clip 속성의 속성값 설정

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

 


[속성값]

 

CSS clip 속성 참고

 

 

clip 예제 - clip 속성값 반환

 

<button type="button" onclick="homzzang()">클릭</button><br>


<img id="hz" style="position:absolute;clip:rect(0,172px,39px,33px);" src="https://i.imgur.com/WfW5mBC.png">


<script>

function homzzang() {

  alert(document.getElementById("hz").style.clip);

}

</script>

 

결과보기

※ 결과값: rect(0px, 172px, 39px, 33px)



분류 제목
DOM_Event JS - loadstart -
DOM_Event JS - message 이벤트 (= onmessage 속성) - 이벤트 메시지 수신 이벤트 (= onmess…
DOM_Event JS - mousedown 이벤트 (= onmousedown 속성) - 마우스버튼누르기 (= mousedow…
DOM_Event JS - mouseenter 이벤트 (= onmouseenter 속성) ★ - 마우스포인터 요소안 이동 (=…
DOM_Event JS - mouseleave 이벤트 (= onmouseleave 속성) ★ - 마우스포인터 요소밖 이동 (=…
DOM_Event JS - mousemove 이벤트 (= onmousemove 속성) - 마우스이동 (= mousemove이벤…
DOM_Event JS - mouseover 이벤트 (= onmouseover 속성) -
DOM_Event JS - mouseout 이벤트 (= onmouseout 속성) -
DOM_Event JS - mouseup 이벤트 (= onmouseup 속성) - 마우스버튼올리기 (= 마우스업벤트)
DOM_Event JS - mousewheel 이벤트 (= onmousewheel 속성 = 온마우스휠 속성) - 마우스휠 이벤…
DOM_Event JS - offline -
DOM_Event JS - online -
DOM_Event JS - open 이벤트 (= onopen 속성) - 이벤트소스와의 연결 열릴 때 이벤트발생 [서버센트이벤트…
DOM_Event JS - pagehide -
DOM_Event JS - pageshow 이벤트 (= onpageshow 속성) - 사용자가 웹페이지 탐색 시 실행 (= p…
44/89
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티
웹유틸
회원센터
홈짱닷컴 PC버전 로그인