<header class="sticky-header">
<div class="logo">MySite</div>
<nav>
<a href="#section1">Section 1</a>
<a href="#section2">Section 2</a>
<a href="#section3">Section 3</a>
</nav>
</header>
<main class="page-content">
<section id="section1" style="height: 600px; background-color: #e9f7ef;"><h1>Section 1</h1></section>
<section id="section2" style="height: 600px; background-color: #fdecea;"><h1>Section 2</h1></section>
<section id="section3" style="height: 600px; background-color: #eaf2f8;"><h1>Section 3</h1></section>
</main>body {
margin: 0;
font-family: Arial, sans-serif;
color: #333;
}
.sticky-header {
position: sticky;
top: 0;
background-color: #2c3e50;
color: white;
padding: 15px 30px;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 1000; /* Ensure it stays on top of other content */
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.sticky-header .logo {
font-size: 1.8em;
font-weight: bold;
}
.sticky-header nav a {
color: white;
text-decoration: none;
margin-left: 20px;
font-size: 1em;
padding: 5px 10px;
border-radius: 4px;
transition: background-color 0.3s;
}
.sticky-header nav a:hover {
background-color: #34495e;
}
.page-content section {
padding: 40px;
box-sizing: border-box;
}
.page-content section h1 {
margin-top: 0;
text-align:center;
}Nothing to show yetType HTML, CSS or JavaScript and your page appears here.
Click any element to find its code Esc
Check this code before you run it
It came from a shared link. It runs with fewer permissions, so it cannot open pop-ups, submit forms or start downloads.
0.00s / 0.00s
Nothing has animated yet. Hover, click or type in the preview and each CSS animation, transition or
element.animate() call shows up here as it plays.