• 회원가입
  • 로그인
  • 구글아이디로 로그인

[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_Style JS - margin -
DOM_Style JS - marginBottom -
DOM_Style JS - marginLeft -
DOM_Style JS - marginRight -
DOM_Style JS - marginTop -
DOM_Style JS - maxHeight -
DOM_Style JS - maxWidth 속성 - 가로최대너비 (= 가로최대길이)
DOM_Style JS - minHeight -
DOM_Style JS - minWidth -
DOM_Style JS - navDown -
DOM_Style JS - navIndex 속성 - 요소의 탭 순서를 설정/반환 (= navIndex속성 = 네브인덱스속성)
DOM_Style JS - navLeft -
DOM_Style JS - navRight -
DOM_Style JS - navUp -
DOM_Style JS - objectFit 속성 - 컨테이너에 맞게 <img>/<video> 크기 조정 방법 지정 (= ob…
DOM_Style JS - objectPosition -
DOM_Style JS - opacity 속성 - 요소의 불투명도 설정/반환 (= opacity속성 = 오패서티속성)
DOM_Style JS - order 속성 - 플렉스아이템 나열순서 (= 오더속성 = flex item order속성, IE1…
DOM_Style JS - orphans 속성 - 인쇄페이지 하단 표시할 요소의 최소줄수 설정/반환 (= orphans속성 =…
DOM_Style JS - outline -
48/67
목록
찾아주셔서 감사합니다. Since 2012