// App.js
import './App.css';
function App() {
return (
<div className='navbar'>
<label className="hamburger-menu">
<input type="checkbox" />
</label>
<div className="logo">Purohit Store</div>
<div className="nav-lists">
<ul>
<li>home</li>
<li>products</li>
<li>contact</li>
<li>about</li>
</ul>
<div>
<button>login</button>
<button>cart</button>
</div>
</div>
</div>
);
}
export default App;
// App.css
*, *::before, *::after{
box-sizing: border-box;
}
body{
margin: 0;
background: #eee;
font-family: sans-serif;
width: 100%;
overflow-x: hidden;
}
.navbar,
.nav-lists,
.navbar ul,
.nav-lists div{
display: flex;
align-items: center;
}
.navbar{
position: sticky;
top: 0;
left: 0;
justify-content: space-between;
padding: 10px 20px;
background-color: #fff;
width: 100%;
z-index: 100;
}
.nav-lists{
gap: 50px;
}
.navbar ul,
.nav-lists div{
gap: 20px;
list-style: none;
}
@media screen and (min-width: 701px) {
.hamburger-menu{
display: none;
}
}
@media screen and (max-width: 700px) {
.nav-lists{
position: absolute;
top: 0;
right: 0;
flex-direction: column;
background-color: #333;
color: white;
margin-top: 3rem;
padding: 2rem;
transition: translate 200ms ease;
translate: 100%;
max-width: 30rem;
min-height: 100vh;
}
.nav-lists ul,
.nav-lists div{
flex-direction: column;
padding: 0;
}
.hamburger-menu {
position: absolute;
top: 10px;
right: 10px;
z-index: 110;
}
.hamburger-menu:has(input:checked) + .nav-lists {
translate: 0;
}
}
[enter image description here][1]
when i check the checkbox nav-lists should be translate to 0 and when i uncheck the checkbox it should translate to 100% but it does not working and nav-lists is overflowing so in body i set overflow is hidden but still it is overflowing. when i do the same thing with navbar it's working but the problem is that app logo and hamburger both included in navbar so i do this with nav-lists but in nav-lists it doesn't work. when i exclude logo and hamburger from navbar and paste it to top of the jsx and include all jsx in one fragment than its working but when i include all this jsx in div instead of jsx fragment it does not work