Mượn hộ khẩu vay tiền vay tín chấp bằng CMND giấy tờ photo
Sure, here's an example of how you can create a sticky header for a website using HTML, CSS, and JavaScript:
HTML:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sticky Header Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header id="header">
<h1>Sticky Header</h1>
</header>
<div class="content">
<!-- Your website content here -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget diam ut elit lobortis commodo. Mauris non metus auctor, vestibulum odio sed, efficitur nisi. Sed dapibus, nisi ac placerat dignissim, lorem libero suscipit odio, et fermentum urna ipsum a risus. Ut vel risus ligula. Aliquam erat volutpat. Nullam ut tellus quis orci vestibulum luctus eu et sapien. Vivamus nec volutpat risus.</p>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS (styles.css):
```css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 1000; /* Ensure header stays above other content */
}
.content {
margin-top: 80px; /* Adjust according to header height */
padding: 20px;
}
/* Style for demonstration purpose */
p {
line-height: 1.5;
font-size: 18px;
}
```
JavaScript (script.js):
```javascript
window.onscroll = function() {stickyHeader()};
var header = document.getElementById("header");
var sticky = header.offsetTop;
function stickyHeader() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
```
In this example, the header will stick to the top of the page when the user scrolls down. You can adjust the styles and JavaScript as needed for your specific website design and functionality.
4.9/5 (92 votes)