position
- position: absolute; -
- 기준: 부모 (box의 경우 부모는 body다)
- 특징: 태그의 부모가 기준이된다.
- position: relative; -
- 기준: 내 위치
- 예시: 태그의 부모로서 relative를 선택해준다.
- position: static;
- 기준이 없어 좌표적용이 필요없다.
- 특징: 기본적인 적용
<!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>
<!--
# position: 기준을 잡아주는 css
- position: absolute; -
- 기준: 부모 (box의 경우 부모는 body다)
- 특징: 태그의 부모가 기준이된다.
- position: fixed;
- 기준: 브라우저
- 특징: 부모와 상관없기에
- position: relative; -
- 기준: 내 위치
- 예시: 태그의 부모로서 relative를 선택해준다.
- position: static;
- 기준이 없어 좌표적용이 필요없다.
- 특징: 기본적인 적용
2.media query
3.tranition / animation
-->
<style>
div {
width: 100%;
min-height: 100px;
height: auto;
border: 1px solid red;
background-color: red;
}
/* relative를 주어 parent를 기준으로 잡는 행위 */
.parent {
position: relative;
}
.target {
position: fixed;
top: 50px;
width: 50%;
right: 0;
border: 3px solid blue;
background-color: blue;
}
/* .box {
width: 100px;
height: 100px;
border: 4px solid red;
top: 100px;
left: 100px;
position: absolute;
} */
</style>
</head>
<body>
<div class="other">other</div>
<div class="parent">
parent
<div class="target">target</div>
</div>
<div class="other">other</div>
<!-- <div class="box"></div> -->
</body>
</html>