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

[background] CSS - background-origin 속성 - 배경이미지 좌표시작점 (= 백그라운드오리진 속성)

목차
  1. background-origin 예제 - 배경이미지 좌표시작점
  2. background-origin 정의
  3. background-origin 구문
  4. background-origin 예제 - 배경이미지 여러 개

 

background-origin 예제 - 배경이미지 좌표시작점 

 

<style>

div {margin-bottom:30px;}

  

#hz1 {

  border: 10px dashed red;

  padding: 25px;

  background: url(https://source.unsplash.com/random);

  background-repeat: no-repeat;

  background-origin: padding-box;

}


#hz2 {

  border: 10px dashed blue;

  padding: 25px;

  background: url(https://source.unsplash.com/random);

  background-repeat: no-repeat;

  background-origin: border-box;

}


#hz3 {

  border: 10px dashed tomato;

  padding: 25px;

  background: url(https://source.unsplash.com/random);

  background-repeat: no-repeat;

  background-origin: content-box;

}

</style>


<div id="hz1">

  <h2>background-origin: padding-box (기본값)</h2>

  <p>홈짱닷컴 Homzzang.com</p>

</div>


<div id="hz2"> 

  <h2>background-origin: border-box</h2>

  <p>홈짱닷컴 Homzzang.com</p>

</div>


<div id="hz3">

  <h2>background-origin: content-box</h2>

  <p>홈짱닷컴 Homzzang.com</p>  

</div>


결과보기

 

background-origin 정의

 

배경이미지 좌표시작 (= 배경 위치 영역) 지정.

 


 

1.

background-attachment:fixed 일 땐, 작동 X.

 

2.

기본값: padding-box

상속여부: X

애니효과: X

CSS버전: CSS3

JS구문: object.style.backgroundOrigin="content-box"

 

3.

IE9 이상 주요 최신 브라우저 지원.

 

 

background-origin 구문

 

selector {background-origin: padding-box|border-box|content-box|initial|inherit;}

 


[속성값]

 

padding-box 

패딩 가장자리의 왼쪽 상단에서 배경이미지 시작. (기본값)

 

border-box

테두리의 왼쪽 상단에서 배경이미지 시작.

 

content-box

내용의 왼쪽 상단에서 배경이미지 시작.

 

initial

이 속성의 기본값으로 설정.

 

inherit

부모요소의 속성값 상속.

 

 

background-origin 예제 - 배경이미지 여러 개

 

<style>

#hz1 {

  border: 10px dashed red;

  padding: 25px;

  background: url(https://i.imgur.com/YrkG5xB.gif), url(https://source.unsplash.com/random);

  background-repeat: no-repeat;

  background-origin: content-box, padding-box;

}


#hz2 {

  border: 10px dashed blue;

  padding: 25px;

  background: url(https://i.imgur.com/YrkG5xB.gif), url(https://source.unsplash.com/random);

  background-repeat: no-repeat;

  background-origin: content-box, border-box;

}


#hz3 {

  border: 10px dashed tomato;

  padding: 25px;

  background: url(https://i.imgur.com/YrkG5xB.gif), url(https://source.unsplash.com/random);

  background-repeat: no-repeat;

  background-origin: content-box, content-box;

}

</style>


<div id="hz1">

  <h2>ackground-origin: content-box, padding-box;</h2>

  <p>홈짱닷컴 Homzzang.com</p>

</div>


<div id="hz2"> 

  <h2>background-origin: content-box, border-box:</h2>

  <p>홈짱닷컴 Homzzang.com</p>

</div>


<div id="hz3">

  <h2>background-origin: content-box, content-box:</h2>

  <p>홈짱닷컴 Homzzang.com</p>  

</div>


결과보기



분류 제목
border CSS - border-style 속성 ★ - 테두리모양일괄 (= border-style속성 = 보더스타일속…
box CSS - padding 속성 ★ - 안쪽여백 (= padding속성 = 패딩속성)
box CSS - min-height 속성 - 최소높이 (= 최소세로길이 = min-height속성 = 민하이트속성…
outline CSS - outline-style (아웃라인스타일) - 테두리 외곽 스타일 (상속 X) : (IE8)
intro CSS - @charset 구문 - 스타일시트 인코딩방식 설정 (= 언어셋지정/문자셋지정 = @charset…
selector CSS - :last-child 가상선택자 - 그 부모의 마지막자식요소인 지정요소 (= :last-child…
border CSS - border-left 속성 - 테두리좌측일괄 (= 테두리왼쪽일괄 = border-left속성 = …
selector CSS - :lang() 가상선택자 - 특정언어속성요소 (= 언어선택자 = 랭선택자, IE8)
list CSS - list-style-position 속성 ★ - 리스트 스타일 위치 (= 리스트 마커 위치 = …
box CSS - max-height 속성 - 최대높이 (= 최대세로길이 = max-height속성 = 맥스하이트속…
selector CSS - element>element 자식선택자 ★ - 직접 자식요소만 선택. (요소선택자, IE7)
text CSS - writing-mode 속성 - 텍스트 방향 가로/세로 제어. (= 글쓰기 방향 = 쓰기 모드 제…
animation CSS - animation-iteration-count 속성 - 애니반복횟수 (= 움직임반복횟수, IE10…
func CSS - hsl() 함수 - (색조, 채도, 밝기)로 색상 정의. (= hsl함수 = 에이치에스엘함수/흐슬…
border CSS - border 속성 ★ - 테두리일괄 (= border속성 = 보더속성) (상속X)
background CSS - background-attachment 속성 - 배경이미지 고정 (= background-atta…
selector CSS - :nth-child() 가상선택자 ★ - 그 부모의 n번째 자식요소 (=nth-child선택자 =…
background CSS - background 속성 ★ - 배경 일괄 (= background속성 = 백그라운드속성)
animation CSS - animation-direction 속성 - 애니방향 (= 움직임방향 = 애니메이션디렉션속성, I…
responsive CSS - Responsive Image - (반응형 이미지) ★★★
22/27
목록
찾아주셔서 감사합니다. Since 2012