File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
starter/09-Omnifood-Optimizations Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 76
76
display : none;
77
77
}
78
78
79
+ /* Sticky navigation */
80
+ .sticky .header {
81
+ position : fixed;
82
+ top : 0 ;
83
+ bottom : 0 ;
84
+ width : 100% ;
85
+ height : 8rem ;
86
+ padding-top : 0 ;
87
+ padding-bottom : 0 ;
88
+ background-color : rgba (255 , 255 , 255 , 0.97 );
89
+ z-index : 999 ;
90
+ box-shadow : 0 1.2rem 3.2rem rgba (0 , 0 , 0 , 0.03 );
91
+ }
92
+
93
+ .sticky .section-hero {
94
+ margin-top : 9.6rem ;
95
+ }
96
+
79
97
/**************************/
80
98
/* HERO SECTION */
81
99
/**************************/
Original file line number Diff line number Diff line change @@ -39,6 +39,27 @@ allLinks.forEach(function (link) {
39
39
} ) ;
40
40
} ) ;
41
41
42
+ //Sticky navigation
43
+
44
+ const sectionHeroEl = document . querySelector ( ".section-hero" ) ;
45
+ const obs = new IntersectionObserver (
46
+ function ( entries ) {
47
+ const ent = entries [ 0 ] ;
48
+ if ( ! ent . isIntersecting ) {
49
+ document . body . classList . add ( "sticky" ) ;
50
+ }
51
+ if ( ent . isIntersecting ) {
52
+ document . body . classList . remove ( "sticky" ) ;
53
+ }
54
+ } ,
55
+ {
56
+ root : null ,
57
+ threshold : 0 ,
58
+ rootMargin : "-80px" ,
59
+ }
60
+ ) ;
61
+ obs . observe ( sectionHeroEl ) ;
62
+
42
63
///////////////////////////////////////////////////////////
43
64
// Fixing flexbox gap property missing in some Safari versions
44
65
function checkFlexGap ( ) {
You can’t perform that action at this time.
0 commit comments