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

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


결과보기



분류 제목
text CSS - word-wrap 속성 ★ - 단어줄바꿈 위해 긴단어쪼개기 (= 긴단어깨기 = 긴단어나누기 = w…
outline CSS - outline-color 속성 - 외곽선두께 (= 아웃라인컬러속성 = outline-color속성…
responsive CSS - RES Frameworks - (반응형 프레임워크) - 반응형홈페이지틀
outline CSS - outline-width (아웃라인위드스) - 테두리 외곽 두께 (상속 X) : (IE8)
box CSS - box-sizing 속성 ★★ - 너비결정방식 (= 길이결정방식 = box-sizing속성 = 박…
animation CSS - animation 속성 ★ - 애니메이션 단축속성 (= animation속성 = 애니메이션속성, …
selector CSS - :empty 가상선택자 - 자식/내용 없는 텅 빈 요소 선택 (= :empty선택자 = 엠프티 선…
selector CSS - ::first-line 가상선택자 - 요소의 첫번째라인 선택 (= ::first-line선택자 =…
css CSS - pointer-events 속성 - 마우스이벤트에 대한 반응 여부 (= pointer-events…
text CSS - overflow-wrap 속성 - 줄바꿈 위해 단어 쪼개기 (= overflow-wrap속성 = …
image CSS - enter an Image (이미지 가운데정렬/중앙정렬)
css CSS - 인스타그램(instagram) 배경색 효과
shadow CSS - text-shadow 속성 - 글자 그림자/음영 효과 주기 (= text-shadow속성 = 텍스…
background CSS - background-size 속성 ★ - 배경이미지 크기 (background-size속성 = 백…
selector CSS - ::selection 가상선택자 - 사용자가 선택한 영역 (= ::selection선택자) (가상…
selector CSS - [attribute|=value] 속성선택자 - 해당속성값 또는 뒤에 하이픈 연결된 속성값 보유 …
box CSS - padding-bottom 속성 - 안쪽여백하단 (= padding-bottom속성 = 패딩바텀속…
selector CSS - [attribute*=value] 속성선택자 - 지정 속성값 문자열 포함 모든 요소 (IE7)
text CSS - text-align-last 속성 - 단락마지막라인정렬 (= text-align-last속성 = …
text CSS - text-decoration-line 속성 - 텍스트라인위치종류 (= text-decoration…
18/27
목록
찾아주셔서 감사합니다. Since 2012