File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,4 +24,51 @@ nav ul li{
2424.dark-nav {
2525 background : # 212EA0 ;
2626 transition : 0.5s ;
27+ }
28+ .menu-icon {
29+ display : none;
30+ }
31+ /* ======= media query ========== */
32+
33+ @media (max-width : 1000px ){
34+ .logo {
35+ width : 140px ;
36+
37+ }
38+ nav ul li {
39+ margin : 10px 15px ;
40+ }
41+ }
42+
43+ @media (max-width : 840px ){
44+ nav {
45+ padding : 15px 0 ;
46+
47+ }
48+ nav ul {
49+ position : fixed;
50+ top : 0 ;
51+ right : 0 ;
52+ background : # 212EA0 ;
53+ z-index : -1 ;
54+ width : 200px ;
55+ bottom : 0 ;
56+ padding-top : 70px ;
57+ transition : 0.5s ;
58+ }
59+ nav ul li {
60+ display : block;
61+ margin : 25px 40px ;
62+ }
63+ .menu-icon {
64+ display : block;
65+ width : 30px ;
66+ cursor : pointer;
67+ }
68+ .btn-nav {
69+ font-size : 14px ;
70+ }
71+ .hide-mobile-menu {
72+ right : -200px ;
73+ }
2774}
Original file line number Diff line number Diff line change 11import React , { useEffect , useState } from 'react'
22import './Navbar.css'
33import logo from '../../assets/logo.png'
4+ import menu_icon from '../../assets/menu-icon.png'
45import { Link } from 'react-scroll' ;
56
67const Navbar = ( ) => {
@@ -9,18 +10,24 @@ const Navbar = () => {
910 window . addEventListener ( 'scroll' , ( ) => {
1011 window . scrollY > 50 ? setSticky ( true ) : setSticky ( false )
1112 } )
12- } , [ ] )
13+ } , [ ] ) ;
14+
15+ const [ mobileMenu , setMobileMenu ] = useState ( false )
16+ const toggleMenu = ( ) => {
17+ mobileMenu ? setMobileMenu ( false ) : setMobileMenu ( true ) ;
18+ }
1319 return (
1420 < nav className = { `container ${ sticky ? 'dark-nav' : '' } ` } >
1521 < img src = { logo } alt = "" className = 'logo' />
16- < ul >
22+ < ul className = { mobileMenu ? '' : 'hide-mobile-menu' } >
1723 < li > < Link to = 'hero' smooth = { true } offset = { 0 } duration = { 500 } > Home</ Link > </ li >
1824 < li > < Link to = 'program' smooth = { true } offset = { - 260 } duration = { 500 } > Program</ Link > </ li >
1925 < li > < Link to = 'about' smooth = { true } offset = { - 150 } duration = { 500 } > About us </ Link > </ li >
2026 < li > < Link to = 'campus' smooth = { true } offset = { - 260 } duration = { 500 } > Campus</ Link > </ li >
2127 < li > < Link to = 'testimonials' smooth = { true } offset = { - 260 } duration = { 500 } > Testimonials</ Link > </ li >
22- < li > < Link to = 'contact' smooth = { true } offset = { - 260 } duration = { 500 } className = 'btn' > Contact Us</ Link > </ li >
28+ < li > < Link to = 'contact' smooth = { true } offset = { - 260 } duration = { 500 } className = 'btn btn-nav ' > Contact Us</ Link > </ li >
2329 </ ul >
30+ < img onClick = { toggleMenu } src = { menu_icon } className = 'menu-icon' alt = "" />
2431 </ nav >
2532 )
2633}
Original file line number Diff line number Diff line change 5151.dark-btn img {
5252 width : 20px ;
5353 margin-left : 10px ;
54+ }
55+ /* ======= media query ========== */
56+
57+ @media (max-width : 1200px ){
58+ .container {
59+ padding-left : 5% ;
60+ padding-right : 5% ;
61+ }
62+ .btn {
63+
64+ padding : 14px 22px ;
65+ }
5466}
You can’t perform that action at this time.
0 commit comments