HTML DOM 스타일 순서 속성은 HTML 문서의 동일한 컨테이너에 있는 나머지 유연한 항목을 기준으로 유연한 항목의 순서를 반환하고 수정합니다.
구문
다음은 구문입니다 -
1. 반품 주문
object.order
2. 순서 수정
object.order = “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;
}
.container {
border: 3px solid #fff;
margin: 1rem auto;
display: flex;
padding: 2rem;
}
.box {
width: 100px;
height: 100px;
}
</style>
<body>
<h1 style="text-align:center">DOM Style order Property Demo</h1>
<div class="container">
<div class="box" id="b1" style="background-color:#7F055F;"></div>
<div class="box" id="b2" style="background-color:#3A015C;"></div>
<div class="box" id="b3" style="background-color:#177E89;"></div>
</div>
<button onclick="set()" class="btn">Change order</button>
<script>
function set() {
document.querySelector('#b1').style.order = "3";
document.querySelector('#b2').style.order = "2";
document.querySelector('#b3').style.order = "1";
}
</script>
</body>
</html> 출력

"주문 변경을 클릭합니다. ” 버튼은 흰색 안의 유연한 항목 순서를 변경합니다. 테두리 컨테이너.
