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

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


결과보기



분류 제목
css CSS - unset 속성값 - 상속값 존재 유무에 따라, inherit・initial 속성값 사용. (= …
selector CSS - [attribute^=value] 속성선택자 ★ - 지정 속성값 문자열로 시작하는 요소. (=시…
border CSS - border-bottom-width 속성 - 테두리하단너비 (= 테두리하단두께 = border-b…
responsive CSS - RES Grid-View - (그리드뷰 = 화면너비분할 = 화면분할 = 수동그리드)
selector CSS - [attribute~=value] 속성선택자 - 특정 속성값단어 (단독 또는 단어앞뒤공백)인 요소…
selector CSS - [attribute$=value] 속성선택자 - 지정 속성값 문자열로 끝나는 요소 (IE7)
selector CSS - :placeholder-shown 가상선택자 - 플레이스홀더 텍스트 표시 중인 요소 선택 (= :…
gradient CSS - linear-gradient() 함수 ★ - 선형 그레이디언트 배경이미지 (= 선형 그라디언트 …
border CSS - border-right-style 속성 - 테두리우측모양 (= border-right-style속…
border CSS - border-top-left-radius 속성 - 테두리상단왼쪽둥글기 지정 (= 보더탑레프트레이디…
shadow CSS - box-shadow 속성 - 요소 그림자 효과 주기 (= box-shadow속성 = 박스섀도속성)…
selector CSS - :only-child 가상선택자 - 그 부모의 유일자식요소 (유일선택자, IE9)
flex CSS - FlexBox (플렉스박스) 소개 ★★★ - 새로운 반응형 레이아웃 모델 ※ (가로/세로) (기본…
flex CSS - flex-basis 속성(I) ★ - 아이템 초기 길이 (= 아이템너비 = flex-basis속성…
column CSS - column-span 속성 - 컬럼 병합 여부 지정 (= 컬럼병합 = 컬럼확장 = column-s…
transform CSS - perspective 속성 - 3D요소의 원근 조망. (= perspective속성 = 퍼스펙티브…
text CSS - text-transform 속성 - 텍스트 대소문자 변환 (= text-transform속성 = …
transform CSS - transform-origin 속성 - 변형요소 위치 변경. ( = transform-origin…
box CSS - padding-right 속성 - 안쪽여백우측 (= padding-right속성 = 패딩라이트속…
gradient CSS - radial-gradient() 함수 ★ - 방사형 그레이디언트 배경이미지 (= 방사형 그라디언트…
17/27
목록
찾아주셔서 감사합니다. Since 2012