Sure! A sticky header is one that stays fixed at the top of the page when a user scrolls. Here's a simple example of how you can achieve that using CSS and [removed]
### HTML
```html
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sticky Header</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="header" id="header">
This is a sticky header
</header>
<!-- Add your content here; it should be enough to scroll down -->
[removed][removed]
</body>
</html>
```
### CSS (styles.css)
```css
body {
margin: 0;
font-family: Arial, sans-serif;
}
.header {
background-color: #333;
color: white;
padding: 10px 20px;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 1000; /* this ensures the header is always on top */
transition: top 0.3s; /* adds a smooth slide-down effect when reappearing */
}
.content {
margin-top: 60px; /* adjust based on the height of the header */
height: 2000px; /* just for demonstration */
}
```
### JavaScript (script.js)
```javascript
window.addEventListener('scroll', function() {
let header = document.getElementById('header');
if (window.pageYOffset > 0) {
// If the user has scrolled down, make the header sticky
header.style.top = '0';
} else {
// If the user is at the top of the page, show the header
header.style.top = '0';
}
});
```
With this setup, the header becomes "sticky" as soon as you scroll down. The CSS transition in the `.header` class ensures that there's a smooth slide-down effect when the header reappears. Adjust the content as needed to see the effect!