File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
starter/07-Omnifood-Desktop Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 3636 display : none;
3737}
3838
39+ .sticky .header {
40+ position : fixed;
41+ top : 0 ;
42+ bottom : 0 ;
43+ width : 100% ;
44+ height : 8rem ;
45+ padding-top : 0 ;
46+ padding-bottom : 0 ;
47+ background-color : rgba (255 , 255 , 255 , 0.97 );
48+ z-index : 999 ;
49+ box-shadow : 0 1.2rem 3.2rem rgba (0 , 0 , 0 , 0.03 );
50+ }
51+
52+ .sticky .section-hero {
53+ /* offset for the difference when removing the header from flow */
54+ margin-top : 9.6rem ;
55+ }
56+
3957/**********************/
4058/* NAVIGATION */
4159/**********************/
Original file line number Diff line number Diff line change @@ -37,6 +37,25 @@ allLinks.forEach((link) => {
3737 } ) ;
3838} ) ;
3939
40+ // Sticky navigation
41+ const observer = new IntersectionObserver (
42+ function ( entries ) {
43+ if ( ! entries [ 0 ] . isIntersecting ) {
44+ document . body . classList . add ( "sticky" ) ;
45+ } else {
46+ document . body . classList . remove ( "sticky" ) ;
47+ }
48+ } ,
49+ {
50+ // In the viewport
51+ root : null ,
52+ // How much of the observed element is in the view port
53+ threshold : 0 ,
54+ rootMargin : "-80px" ,
55+ }
56+ ) ;
57+ observer . observe ( document . querySelector ( ".section-hero" ) ) ;
58+
4059///////////////////////////////////////////////////////////
4160// Fixing flexbox gap property missing in some Safari versions
4261function checkFlexGap ( ) {
You can’t perform that action at this time.
0 commit comments