HTML, CSS

(50)CSS_sticky

빠스무 2023. 4. 3. 16:40
728x90
 

(35)CSS_태그 설명

font-size 텍스트 크기를 설정 px, %, em, rem font-family 텍스트의 글꼴을 설정 ✔ 글꼴을 선택하는 방법 누구나 설치되어 있는 기본 글꼴을 사용 이미지로 처리 클라리언트에 글꼴을 다운로드 시켜 사

jm-rograming.tistory.com

 

<!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>sticky</title>
    <style>
        html, body {margin: 0; padding: 0;}
        .header{
            height: 80px;
            background-color: gold;
        }
        .container{
            display: flex;
            flex-flow: row nowrap;
        }
        .content{
            box-sizing: border-box;
            width: 80%;
            height: 800px;
            background-color: deepskyblue;
        }
        .sidebar{
            position: sticky;
            box-sizing: border-box;
            width: 20%;
            background-color: deeppink;
            height: 400px;
            top: 0;/*상위 부모 컨테이너의 가장 산단에서 부터 적용*/
        }
        .footer{
            background-color: seagreen;
            height: 200px;
        }
    </style>
</head>
<body>
    <header class="header">헤더</header>
     <main class="container">
        <section class="content">메인 컨텐츠</section>
        <aside class="sidebar">Sticky 적용하기</aside>
     </main>
     <footer class="footer">푸터</footer>
</body>
</html>