Skip to content

Commit

Permalink
added responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyaaa1 committed May 2, 2024
1 parent 0066037 commit da30e96
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/Components/Navbar/Navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,46 @@ nav ul li{
.dark-nav{
background: #212EA0;
transition: 0.5s;
}

.menu-icon{
display: none;
}

@media(max-width: 1000px){
.logo{
width: 140px;
}
nav ul li{
margin: 10px 15px;
}
}

@media(max-width: 840px){
nav{
padding: 15px 0;
}
nav ul{
position: fixed;
top: 0;;
right: -200px;
bottom: 0;
background: #212EA0;
z-index: -1;
width: 200px;
padding-top: 70px;
transition: 0.5s;
}
nav ul li{
display: block;
margin: 25px 40px;
}
.menu-icon{
display: block;
width: 30px;
cursor: pointer;
}
.hide-mobile-menu{
right: -200px;
}
}
9 changes: 8 additions & 1 deletion src/Components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link } from 'react-scroll';

import './Navbar.css'
import logo from '../../assets/logo2.png'
import menu_icon from '../../assets/menu-icon.png'
import { NavLink } from 'react-router-dom';

const Navbar = () => {
Expand All @@ -15,10 +16,15 @@ const Navbar = () => {
})
},[]);

const [mobileMenu, setMobileMenu] = useState(false);
const toggleMenu = ()=>{
mobileMenu ? setMobileMenu(false) : setMobileMenu(true);
}

return (
<nav className={`container ${sticky? 'dark-nav' : ''}`}>
<img src={logo} alt='' className='logo'></img>
<ul>
<ul className={mobileMenu?'':'hide-mobile-menu'}>
<li><Link to='hero' smooth={true} offset={0} duration={500}>Home</Link></li>
<li><Link to='about' smooth={true} offset={-260} duration={500}>About</Link></li>
<li><Link to='testimonials' smooth={true} offset={0} duration={500}>Testimonials</Link></li>
Expand All @@ -28,6 +34,7 @@ const Navbar = () => {
<li><NavLink to='/login'>Login</NavLink></li>
<li><NavLink to='/signup'>Signup</NavLink></li>
</ul>
<img src={menu_icon} alt='' className='menu-icon' onClick={toggleMenu}></img>
</nav>
)
}
Expand Down
11 changes: 11 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ a{
.btn.dark-btn{
background: #212EA0;
color: #fff;
}


@media(max-width: 1200px){
.container{
padding-left: 5%;
padding-right: 5%;
}
.btn{
padding: 14px 22px;
}
}

0 comments on commit da30e96

Please sign in to comment.