-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from VidhiyaSB/master
Sticky Headers
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |