
background-color:green;
/*고유 색으로 지정한다*/
background-img:url("img_tree.gif");
/*이미지로 지정한다*/
background-repeat:no-repeat;
/*배경을 반복할지 묻는다*/
background-position:top center;
/*어떻게 정렬할지 선택한다*/
background-attachment:scroll;
/*배경을 고정할지 스크롤함에 따라 같이 움직일지 선택한다*/
/*축약형*/
background:green url("img_tree.gif") no-repeat fixed center;
/*한번에 배경 속성을 입력한다
이 경우 배경은 녹생이며 img_tree.gif가 삽입된다, 반복되지 않으며 배경은 움직이지 않고
고정되며 가운데 정렬된다*/
div{
background-color:pink;
}
span{
background-color:pink;
}
<div>배경변경</div>
<span>배경변경</span>

div{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
}

div.a{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
background-repeat:repeat-x;
font-size:500%;
}
div.b{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
background-repeat:repeat-y;
font-size:500%;
}
div.c{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
background-repeat:space;
font-size:500%;
}
div.d{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
background-repeat:no-repeat;
font-size:500%;
}
div.e{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
background-repeat:space repeat;
font-size:500%;
}
div.f{
height:500px;
background-color:yellow;
background-image:url(cherry-tree.png);
background-repeat:round;
font-size:500%;
}

앞의 값이 X축 뒤에 값은 Y축으로 지정된다
left center : x축은 가장 왼쪽 y축은 가운데로 지정된다.
표처럼 인식하면 된다
| left top | center top | right top |
|---|---|---|
| left center | center center | right center |
| left bottom | center bottom | right bottom |
%값으로 지정할수 있다 각각 (x축의 %) (y축의 %)가 된다.
표와같이 인식할수있으며 %로 구체적인 값을 조절가능하다
| 0% 0% | 50% 0% | 100% 0% |
|---|---|---|
| 0% 50% | 50% 50% | 100% 50% |
| 0% 100% | 50% 100% | 100% 100% |
그 외에도 %와 마찬가지로 10px 100px등 px값을 입력할수있다.
bottom right 값을 입력하여 조절할수있다
| bottom 0% right 0% | ||
|---|---|---|
| bottom 50% right 50% | ||
| bottom 100% right 100% |
이처럼 구체적으로 top left를 입력하여 그 뒤에 수치를 주어 조절이 가능하다
| 기본값 | top | |
|---|---|---|
| left | center | right |
| bottom |
**/* 키워드 값 */
background-attachment: scroll;
background-attachment: fixed;
background-attachment: local;
/* 전역 값 */
background-attachment: inherit;
background-attachment: initial;
background-attachment: unset;**
실행결과 : https://hana78786.github.io/Study_hana/bostcourse_htmlcss/5-3.html