박스모델, 마진병합, display, vertical-align, position
github 소스코드: https://github.com/YesolLee421/DaeguAISchool2021/tree/main/EX_4 index.html, css/style.css
margin: border 바깥쪽padding: border 안쪽, content 바깥쪽box-sizing: border-box ->제작한 공간 용량 안에서 border, padding 적용해줌.box-model {
    margin: 100px 0 0 100px;
    padding: 100px 0 0 100px;
    box-sizing: border-box;
    
    margin-left: 100px;
    margin-top: 100px;
    padding-top: 100px;
    padding-left: 100px;
}
position 속성 이용.margin-one {
    width: 100%;
    height: 100px;
    background-color: yellow;
    margin-bottom: 100px;
}
.margin-two {
    width: 100%;
    height: 100px;
    background-color: blue;
    margin-top: 150px;
}
.margin-parent {
    width: 300px;
    height: 300px;
    background-color: blueviolet;
}
.margin-child {
    position: absolute;
    width: 150px;
    height: 150px;
    background-color: chartreuse;
    margin-top: 100px;
}
html 요소는 block, inline 둘 중 하나의 진영에 속하게 된다. display 속성은 태그의 진영을 바꾸는 속성으로 x축 정렬이면서(inline) 공간 점유 및 상하좌우 배치 가능(block)하도록 inline-block값을 줄 수 있다.
h1 {
    width: 100px;
    height: 100px;
    background-color: chartreuse;
    margin-top: 100px;
    display: inline-block;
}
span {
    width: 100px;
    height: 100px;
    background-color: chocolate;
    margin-top: 100px;
    display: block;
}
형제 관계의 태그들 중 가장 크기가 큰 것을 기준으로 가로로 놓인 요소들을 정렬한다. inline요소에만 사용할 수 있으며 <img>태그의 경우 원래부터 inline-block속성을 가지고 있어 정렬이 가능하다.
<span class="inline">inline</span>
<span class="inline-block">inline-block</span>
<img src="https://via.placeholder.com/200" alt="">
<h1>block</h1>
.inline-block {
    display: inline-block;
    width: 100px;
    height: 100px;
    background-color: chocolate;
}
.inline-block, .inline, img {
    vertical-align: middle;
}
position: 웹사이트 요소를 2차원으로 할지 3차원으로 할지 결정함
| 경우의 수 | static | fixed | relative | absolute | 
|---|---|---|---|---|
| 차원 | 2차원 | 3차원 | 2차원+3차원 | 3차원 | 
| 부모자식간 마진병합 | 일어남 | 안 일어남 | 일어남 | 안 일어남 | 
| top속성 사용 | 사용불가 | 사용가능 (브라우저 기준) | 사용가능(최초 위치 기준) | 사용가능(부모에 따라 기준 변화) | 
| 자식의 높이값 부모영향 | 영향 줌 | 영향 안 줌 | 영향 줌 | 영향 안 줌 | 
absolute: 부모가 2차원이면 top등 이동 속성이 브라우저 상단 왼쪽 기준 / 부모가 3차원이면 최초 위치 기준github 소스코드: https://github.com/YesolLee421/DaeguAISchool2021/tree/main/EX_4 position.html, css/position-style.css
static: 마진병합은 부모가 2차원일 때 일어남(static, relative), top 사용불가, 길이는 영향 줌fixed: 마진병합 안일어남, top사용가능, 길이 영향 안 줌 (부모 position 영향 없음)relative: 마진병합은 부모가 2차원일 때 일어남(static, relative), top 사용가능, 길이 영향 줌absolute: 마진병합 안일어남, top 사용가능(부모가 static일 때만 브라우저 기준), 길이 영향 안 줌오늘 요소의 위치를 결정하는 속성들을 많이 배웠다. 특히 요소들을 가로로 두는 방법을 알게 되었으니 더 다양한 레이아웃을 구현할 수 있을 것 같다. 또한 어제 before, after 등을 설정하려고 인터넷 검색했을 때 나왔던 수많은 설정 중 display, position 등의 의미를 알게 되어 기분이 좋다.