CSS의 fixed position으로 메뉴바 상단 고정 | 달레의 웹 프로그래밍
https://codepen.io/daleseo/pen/YzKLKLj
관련 사이트 : https://codepen.io/features/pro
<header>
<h1>Brand</h1>
<nav>
<span>Menu1</span>
<span>Menu2</span>
<span>Menu3</span>
</nav>
</header>
<main>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
<p>This is the main area.</p>
</main>
<style>
header {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 75px;
padding: 1rem;
color: white;
background: teal;
font-weight: bold;
display: flex;
justify-content: space-between;
align-items: center;
}
h1, p {
margin: 0;
}
main {
padding: 1rem;
height: 100%;
}
body {
padding-top: 75px;
background: #EEE;
}
body, html {
height: 200%;
}
* {
box-sizing: border-box;
}
</style>
https://www.daleseo.com/css-position-fixed-navigation/
CSS의 fixed position으로 메뉴바 상단 고정 | 달레의 웹 프로그래밍