스타일 backgroundImage 속성
예시
문서의 배경 이미지 설정:
document.body.style.backgroundImage = "url('img_tree.png')";
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
backgroundImage 속성은 요소의 배경 이미지를 설정하거나 반환합니다.
팁: background-image 외에 background-color도 지정해야 합니다. 이미지를 사용할 수 없는 경우 배경색이 사용됩니다.
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
backgroundImage | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
통사론
backgroundImage 속성을 반환합니다.
object.style.backgroundImage
backgroundImage 속성을 설정합니다.
object.style.backgroundImage = "url('URL')|none|initial|inherit"
속성 값
Value | Description |
---|---|
url('URL') | The location of the image file |
none | No background image. This is default |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
기술적 세부 사항
기본값: | 없음 |
---|---|
반환 값: | 배경 이미지를 나타내는 문자열 |
CSS 버전 | CSS1 |
더 많은 예
예시
특정 <div> 요소의 배경 이미지를 설정합니다.
document.getElementById("myDiv").style.backgroundImage = "url('img_tree.png')";
예시
특정 <div> 요소의 배경 이미지를 반환합니다.
alert(document.getElementById("myDiv").style.backgroundImage);
예시
문서의 배경 이미지를 반환합니다.
alert(document.body.style.backgroundImage);
관련 페이지
CSS 튜토리얼: CSS 배경
CSS3 튜토리얼: CSS3 배경
CSS 참조: background-image 속성
HTML DOM 참조: 배경 속성