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

[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)



분류 제목
CSS_Objects JS - setProperty() 메서드 - 새 CSS속성설정 / 기존CSS속성수정 (= setPropert…
DOM JS - NodeList 속성 - 노드리스트 (= 노드목록)
Basic JS - this 키워드 ★★★★★ - 호출 방식에 따라 지시 대상 다름. (= 디스 키워드)
Functions JS - apply() 메서드 - 함수호출방법3 (= 어플라이메서드)
Functions JS - Closure - 클로저 (전역변수/지역변수/카운터)
Math JS - Math.atanh() 메서드 - 쌍곡선 아크탄젠트 (IE12 이상)
Math JS - Math.acosh() 메서드 - 쌍곡선 아크코사인 (IE12 이상)
Math JS - Math.asinh() 메서드 - 쌍곡선 아크사인 반환 (= asinh 메서드)
Math JS - Math.cbrt() 메서드 - 세제곱근
Math JS - Math.tanh() 메서드 - 쌍곡선 탄젠트 (IE12 이상)
Math JS - Math.trunc() 메서드 - 숫자의 정수부분 추출 (= trunc메서드 = 트런크메서드) (I…
Math JS - Math.cosh() 메서드 - 쌍곡선 코사인
Math JS - Math.sinh() 메서드 - 쌍곡선 사인값 (IE12 이상)
DOM_Event JS - initMouseEvent() 메서드 - 폐기예고. 마우스이벤트초기화
js JS - getRangeAt() 메서드
DOM_Document JS - styleSheets 속성 - 스타일시트집합
js JS - rules 속성 - styleSheets 객체의 속성
DOM_Event JS - cancelBubble 속성 - 부모요소로 이벤트 확산 방지 (= 상위요소로 이벤트확산취소 = 캔슬…
DOM_Event JS - composedPath() 메서드 - 이벤트객체흐름파악 (=이벤트실행객체경로파악 = 컴포우즈드패스메…
js JS - 특정요소 함수실행제외 (= 배열문자열포함검사) ★★★★★
61/67
목록
찾아주셔서 감사합니다. Since 2012