스타일 backgroundRepeat 속성은 배경 이미지가 반복되는 방식을 설정하거나 가져오는 데 사용됩니다.
구문
다음은 −
의 구문입니다.backgroundRepeat 속성 설정하기 -
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|no-repeat|initial|inherit"
값
다음은 위의 속성 값입니다 -
| Sr.No | 값 및 설명 |
|---|---|
| 1 | 반복 이것은 기본값입니다. 배경 이미지를 세로 및 가로로 반복합니다. |
| 2 | 반복 x 이것은 배경 이미지를 가로로만 반복합니다. |
| 3 | 반복-y 이것은 배경 이미지를 세로로만 반복합니다. |
| 4 | 반복 없음 배경 이미지를 반복하지 않습니다. |
예시
backgroundRepeat 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("https://www.tutorialspoint.com/power_bi/images/power-bi-minilogo.jpg");
background-repeat: repeat-x;
color:black;
font-size:20px;
}
</style>
<script>
function changeBackRepeat(){
document.body.style.backgroundRepeat="repeat-y";
document.getElementById("Sample").innerHTML="The background image is now repeated vertically";
}
</script>
</head>
<body>
<h2>Demo Heading</h2>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p>Change the body background image repeat value by clicking the below button</p>
<button onclick="changeBackRepeat()">CHANGE REPEAT</button>
<p id="Sample"></p>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

CHANGE REPEAT 버튼을 클릭하면 -
