fixed 질문

fixed 질문

QA

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

내용이 이해가 안가네요 

green-box 는 absolute 인데 pink 랑 같이 움직이게 하고 싶다구요?

green-box 를 pink 랑 같은 div 로 묶으면 되지 않나요?

 

그렇게 하기 싷으면 세로 스크롤 생길때마다 green-box 의 위치를 조정해줘야죠

 

답변을 작성하시기 전에 로그인 해주세요.
전체 59,556
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT