반응형
<!DOCTYPE html>
<html lang="kr">
<head>
<title>The Nick Times</title>
<style>
body {
height: 1000vh;
margin: 20px;
}
div {
width: 300px;
height: 300px;
background-color: teal;
}
#different {
top: 5px;
left: 200px;
position: fixed;
background-color: wheat;
width: 350px;
}
</style>
</head>
<body>
<div></div>
<div id="different"></div>
</body>
</html>
top, left, right, bottom 이라는 프로퍼티 중에서
하나만 수정해도
노란색 div는 초록색 div 위로 가게 되어 있다.
(더 이상 block이든 margin이든 뭐든 신경쓰지 않는다.)
결과
(스크롤 시 노란색 div는 그 자리에 고정되어 있음 / 완전히 다른 레이어가 된다)
반응형
'2. CSS' 카테고리의 다른 글
CSS position absolute 사용해서 div 박스 옮기기 이동 (0) | 2024.11.26 |
---|---|
CSS position relative 사용해서 div 박스 옮기기 (0) | 2024.11.26 |
CSS position fixed 사용하기 (0) | 2024.11.24 |
CSS flex-wrap 사용하기 (0) | 2024.11.19 |
CSS flex 태그: 자식 엘리먼트를 flex 컨테이너로 만들기 (0) | 2024.11.19 |