CSS 배경 속기
CSS 배경 - 약식 속성
코드를 줄이기 위해 모든 배경 속성을 하나의 속성으로 지정할 수도 있습니다. 이것을 약식 속성이라고 합니다.
쓰는 대신:
body {
background-color: #ffffff;
background-image:
url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
약식 속성을 사용할 수 있습니다 background
.
예시
속기 속성을 사용하여 하나의 선언에서 배경 속성을 설정합니다.
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
약식 속성을 사용할 때 속성 값의 순서는 다음과 같습니다.
background-color
background-image
background-repeat
background-attachment
background-position
속성 값 중 하나가 누락되어도 다른 값이 이 순서대로 있는 한 문제가 되지 않습니다. 위의 예에서 background-attachment 속성은 값이 없기 때문에 사용하지 않습니다.
모든 CSS 배경 속성
Property | Description |
---|---|
background | Sets all the background properties in one declaration |
background-attachment | Sets whether a background image is fixed or scrolls with the rest of the page |
background-clip | Specifies the painting area of the background |
background-color | Sets the background color of an element |
background-image | Sets the background image for an element |
background-origin | Specifies where the background image(s) is/are positioned |
background-position | Sets the starting position of a background image |
background-repeat | Sets how a background image will be repeated |
background-size | Specifies the size of the background image(s) |