HTML onresize 속성은 사용자가 브라우저 창의 크기를 조정할 때 트리거됩니다.
구문
다음은 구문입니다 -
<tagname onresize=”script”></tagname>
HTML onresize 이벤트 속성의 예를 살펴보겠습니다 -
예시
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
padding: 20px;
}
</style>
</head>
<body onresize="resizeFn()">
<h1>HTML onresize Event Attribute Demo</h1>
<p>Now resize the browser window</p>
<script>
function resizeFn() {
document.body.style.background = 'linear-gradient(45deg, #8BC6EC 0%, #9599E2 100%) no-repeat';
}
</script>
</body>
</html> 출력

이제 브라우저 창의 크기를 조정하여 onresize 이벤트 속성이 작동하는 방식을 관찰합니다.
