fixed 질문
본문
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Code Challenge</title>
</head>
<body>
<!-- 빨간박스 -->
<div class="pink-box"></div>
<!-- 파란박스 -->
<div class="blue-box">This is the day one</div>
<!-- 노란박스 및 초록박스 -->
<div class="yellow-box">
<div class="green-box"></div>
</div>
</body>
</html>
body{
height: 1500px;
position: relative;
padding: 0;
margin: 0;
}
.pink-box{
width: 100%;
height: 200px;
background-color: pink;
position: fixed;
z-index: 1;
}
.blue-box{
width: 75%;
height: 100%;
background-color: blue;
position: absolute;
top: 200px;
padding: 50px;
box-sizing: border-box;
color: #fff;
font-size: 40px;
font-weight: bold;
}
.yellow-box{
width: 25%;
height: 100%;
top: 200px;
background-color: yellow;
position: absolute;
right: 0;
box-sizing: border-box;
border: 5px solid gray;
}
.green-box{
width: 150px;
height: 70px;
background-color: green;
position: absolute;
top: -35px;
left: -75px;
z-index: 3;
}
여기에서 green-box 를 fixed 하여 pink박스와 동일하게 내려오게 하고싶은데요
반응형에 맞게 움직이면서 스크롤 내릴시 pink 박스와 같이 내려오게 하는 방법이 없을까요 ?
!-->!-->답변 2
<div pink-box><din green-box style="position:absolute"></div></div>
이런식???
내용이 이해가 안가네요
green-box 는 absolute 인데 pink 랑 같이 움직이게 하고 싶다구요?
green-box 를 pink 랑 같은 div 로 묶으면 되지 않나요?
그렇게 하기 싷으면 세로 스크롤 생길때마다 green-box 의 위치를 조정해줘야죠
답변을 작성하시기 전에 로그인 해주세요.