HTML DOM 스타일 관점 속성은 HTML 문서에서 3D 요소가 표시되는 방식을 반환하고 수정합니다.
구문
다음은 구문입니다 -
1. 관점의 회귀
object.perspective
2. 관점 수정
object.perspective = “value”
여기서 값 수 -
| 값 | 설명 |
|---|---|
| 초기 | 이 속성 값을 기본값으로 설정합니다. |
| 상속 | 상위 요소에서 이 속성 값을 상속합니다. |
| 없음 | 관점을 설정하지 않습니다. |
| 길이 | 요소가 뷰에서 얼마나 멀리 떨어져 있는지를 길이 단위로 지정합니다. |
HTML DOM 스타일 관점 속성의 예를 살펴보겠습니다 -
예시
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
.box {
text-align: center;
width: 200px;
height: 200px;
background-color: #db133a;
transform: rotateX(25deg);
margin: 2rem auto;
}
</style>
<body>
<h1 style="text-align:center">DOM Style perspective Property Demo</h1>
<div class='box'></div>
<button class="btn" onclick="set()">Set Perspective</button>
<script>
function set() {
document.body.style.perspective = "100px";
}
</script>
</body>
</html> 출력

"관점 설정을 클릭합니다. ” 버튼을 눌러 빨간색 의 원근감을 설정합니다. 상자.
