File tree 3 files changed +55
-0
lines changed
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < title > Sticky Header Example</ title >
7
+ < link rel ="stylesheet " href ="style.css ">
8
+ </ head >
9
+ < body >
10
+ < header class ="sticky-header ">
11
+ < h1 > My Sticky Header</ h1 >
12
+ </ header >
13
+
14
+ < div class ="content ">
15
+ < h2 > Welcome to the Sticky Header Demo</ h2 >
16
+ < p > Scroll down to see the header stick to the top of the page.</ p >
17
+ </ div >
18
+
19
+ < div class ="long-content ">
20
+ < h3 > Scrollable Content</ h3 >
21
+ < 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 >
22
+ <!-- You can add more paragraphs or content here -->
23
+ </ div >
24
+ </ body >
25
+ </ html >
Original file line number Diff line number Diff line change
1
+ body {
2
+ margin : 0 ;
3
+ font-family : Arial, sans-serif;
4
+ line-height : 1.6 ;
5
+ }
6
+
7
+ .sticky-header {
8
+ position : sticky;
9
+ top : 0 ;
10
+ background-color : # 333 ;
11
+ color : # fff ;
12
+ padding : 20px ;
13
+ z-index : 100 ;
14
+ }
15
+
16
+ .sticky-header h1 {
17
+ margin : 0 ;
18
+ }
19
+
20
+ .content {
21
+ padding : 20px ;
22
+ }
23
+
24
+ /* Adding more content to ensure scrolling */
25
+ .long-content {
26
+ height : 2000px ;
27
+ background : linear-gradient (to bottom, # f1f1f1, # ddd );
28
+ padding : 20px ;
29
+ margin-top : 20px ;
30
+ }
You can’t perform that action at this time.
0 commit comments