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
- 게임
- setTimeout()
- Project
- eport
- object
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- execCommand
- 비동기
- js
- 혼프
- db
- Porject
- webpack
- https://m.blog.naver.com/tt2t2am1118/221010125300
- database
- JS #프로젝트
- 참고블로그
- promise
- Import
- async
- await
- mysql
- json
- slow and steady
- addEventListener
- callback
- 동기
- sql
- ajax
- prj
Archives
- Today
- Total
C-log
💅✨Decorate from CSS : margin 겹침/중첩(3) 본문
728x90
이번 포스팅은 지난번 border 값을 제거했을 때 해당 요소가 밀리는 margin 겹침/중첩 현상을 다루어 볼 것이다. 우선 코드를 살펴보면 아래와 같다.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="./style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="empty"></div>
<div id="normal">normal</div>
</body>
</html>
#empty {
margin-top: 50px;
margin-bottom: 100px;
border: 1px solid tomato;
}
#normal {
background-color: powderblue;
margin-top: 100px;
}
현재 normal요소에 margin-top을 100px를 주었을 때 아무런 변화가 없다. 이는 중첩 현상 때문이다. 따라서 normal 요소가 움직이게 되려면 100px보다 크다면 아래로 움직이게 될 것이다. 여기까지는 우리 모두가 알고 있는 부분이다. 하지만 여기서 empty 요소에 border값을 제거하게 되면 아래와 같은 결과가 된다.
왜 border값을 제거하면 위로 올라가게 되는 것일까? border의 시각적으로 보여지는 것의 여부로 margin의 중첩현상 차이가 생기는 것이다. 즉, 시각적 요소 콘텐츠, 박스 선딩이 없을 때 margin의 가장 큰 마진 하나만 먹이게 되는 것이다. 반대로 존재할 때는 우리가 알고 있는 중첩현상이 발생하는 것이다. 정확하게 margin 중첩현상이 누굴 위해서 왜 일어나는진 이유가 명화하진 않지만 이러한 차이가 있다는 것을 인지하고 css를 작성하면 좋을 듯하다.
728x90
'💅CSS > ⚡ver.0' 카테고리의 다른 글
💅✨Decorate from CSS : margin 겹침/중첩(2) (0) | 2024.02.20 |
---|---|
💅✨Decorate from CSS : margin 겹침/중첩(1) (0) | 2024.02.20 |
💅✨Decorate from CSS : box-sizing (0) | 2024.02.20 |
💅✨Decorate from CSS : box model (0) | 2024.02.20 |
💅✨Decorate from CSS : inline block (0) | 2024.02.19 |
Comments