CSS 32 z-index 속성
프론트엔드/CSS2021. 4. 4. 10:49
z-index
- 한 요소 위에 다른 요소를 쌓을 때 사용
- z-index 속성값이 작을수록 아래에 쌓임
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#box1{position: absolute;top: 0px; left: 0px;width: 100px; height: 100px;background: blue;
z-index: 3;} /*z-index를 3으로 설정하였습니다.*/
#box2{position: absolute;top: 30px; left: 30px;width: 100px; height: 100px;background: yellow;
z-index: 2;} /*z-index를 2으로 설정하였습니다.*/
#box3{position: absolute;top: 60px; left: 60px;width: 100px; height: 100px;background: green;
z-index: 1;} /*z-index를 1으로 설정하였습니다.*/
</style>
</head>
<body>
<div id="box1">box #1</div>
<div id="box2">box #2</div>
<div id="box3">box #3</div>
</body>
</html>
'프론트엔드 > CSS' 카테고리의 다른 글
CSS 34 로그인 폼 만들기 (0) | 2021.04.04 |
---|---|
CSS 33 table 꾸미기 (2) | 2021.04.04 |
CSS 31 position 속성 (0) | 2021.04.04 |
CSS 30 float 속성으로 웹페이지 구성해보기 (0) | 2021.04.04 |
CSS 29 float 속성, clear 속성, overflow 속성 (0) | 2021.04.03 |
댓글()