Skip to content

Commit

Permalink
Merge pull request #479 from VidhiyaSB/master
Browse files Browse the repository at this point in the history
Sticky Headers
  • Loading branch information
aayush105 authored Oct 4, 2024
2 parents 630ca32 + f73a59b commit 82265b3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
25 changes: 25 additions & 0 deletions stickyheader/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!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="style.css">
</head>
<body>
<header class="sticky-header">
<h1>My Sticky Header</h1>
</header>

<div class="content">
<h2>Welcome to the Sticky Header Demo</h2>
<p>Scroll down to see the header stick to the top of the page.</p>
</div>

<div class="long-content">
<h3>Scrollable Content</h3>
<p>This is a long content area to demonstrate the sticky header effect. As you scroll, you'll notice that the header at the top remains in place.</p>
<!-- You can add more paragraphs or content here -->
</div>
</body>
</html>
Binary file added stickyheader/output.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions stickyheader/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
body {
margin: 0;
font-family: Arial, sans-serif;
line-height: 1.6;
}

.sticky-header {
position: sticky;
top: 0;
background-color: #333;
color: #fff;
padding: 20px;
z-index: 100;
}

.sticky-header h1 {
margin: 0;
}

.content {
padding: 20px;
}

/* Adding more content to ensure scrolling */
.long-content {
height: 2000px;
background: linear-gradient(to bottom, #f1f1f1, #ddd);
padding: 20px;
margin-top: 20px;
}

0 comments on commit 82265b3

Please sign in to comment.