Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- MySQL
- java
- 조코딩
- 자바 강제 캐스팅
- 자바 if문
- 자바 for문
- 자바 반복문
- 자바 스캐너
- 자바 조건문
- 항해99 2기
- 자바 switch문
- 자바 자동캐스팅
- 이클립스 DB연동
- 타입스크립트
- 프로그래머스
- 항해99
- react ag grid
- 자바 삼항연산자
- 자바 while문
- Vue3
- 자바 구구단 출력
- Til
- 자바 public
- 정보처리기사실기
- TypeScript
- 자바 공배수
- 자바 향상된 for문
- 자바
- react with typescript
- 변수
Archives
- Today
- Total
뇌 채우기 공간
[html][css] position요소 쌓임 순서 stack order 본문
어떤 요소가 더 위에 쌓이는지?
1. static을 제외한 position속성의 값이 있을 경우 가장 위에 쌓임(값은 무관)
2. position이 모두 존재한다면 z-index값이 높을수록 위에 쌓임
3. postion 속성의 값이 있고, z-index 값이 같다면
html의 마지막 코드일 수록 위에 쌓임
position> z-index> html마지막 코드
<div class="box-group">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
</div>
.box-group{
display: flex;
}
.box-group .box{
width: 100px;
height: 100px;
background: tomato;
border: 4px dashed red;
border-radius: 30px;
font-size: 30px;
display: flex;
justify-content: center;
align-items: center;
margin-right: -30px;
}
.box-group .box:nth-child(2n){
margin-top: 30px;
}
가장 늦게 작성된 5번이 가장 위에 있다.
그런데 4번 박스에
postion: relative를 적어놓는다면
4번이 가장 위에 쌓인다.
.box3{
position: relative;
z-index:1;
}
box3번에 z-index를 높여주면 3번이 올라간다.
그런데 주의할 점은 position이 있어야한다.
728x90