• 카테고리

    질문 & 답변
  • 세부 분야

    취업 · 이직

  • 해결 여부

    미해결

스크롤 시 헤더 fixed에 관해 질문드립니다

21.06.13 01:17 작성 조회수 311

1

헤더를 상단 fixed할경우 이게 공중에 붕뜨는 것처럼 아래있던 intro섹션이 위로 끌려오게 되는데 intro 섹션에 padding-top을 줘서 header와 간격을 벌려주는게 맞는지 궁금합니다

    /* header */
    #header {
        positionfixed;
        top0;
        left0;
        width100%;
        z-index99;
    }
    .header-inner {
        marginauto;
        height100%;
        border1px solid #000;
    }
    nav {
        max-width1440px;
        text-alignright;
        height70px;
        line-height70px;
    }
    nav a {
        margin-right10px;
    }
        * {
            margin0;
            padding0;
        }
        a {
            text-decorationnone;
            color#fff;
        }
    #header {
    }
    #intro {
        height400px;
        padding-top70px;
        background-color#CCB9AF;
   }
    </style>
</head>
<body>
    <header id="header">
        <div class="header-inner">
            <nav>
                <a href="#intro">HOME</a>
                <a href="#about">ABOUT</a>
                <a href="#skills">SKILLS</a>
                <a href="#pratical">Pratical</a>
                <a href="#mobile">Mobile Web&App</a>
                <a href="#none">WebSite Publising</a>
              </nav>
        </div>
    </header>
    <section id="intro"></section>

답변 1

답변을 작성해보세요.

1

네. header에 포지션 absolute 또는 fixed가 되면 떠서 위치를 잡기 때문에 공간이 생겨서 아래 요소가 올라갑니다. 곧 intro 섹션이 올라가기 때문에 헤더의 높이 만큼 intro 섹션의 상단이 덜 보이게 됩니다. 

말씀하신 것처럼 intro 섹션에만 패딩 상단을 더 주어서 조절하시면 됩니다.

운동님의 프로필

운동

2022.09.02

와...대박...그렇구나..

감사합니다!!!