Please help me to fix this CSS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please help me to fix this CSS

Hello coders, I'm trying to help my friend by building a restaurant site for her. So far, I took design from her and trying to implement it in code. I was able to code hamburger with pure css. When I click on the hamburger icon, I want the li's to be displayed on the center of the page with a background of black so that the main image gets hidden. Right now, when you click on hamburger, li's are displayed towards left. Could you help me to figure out that portion of the code? Link - https://code.sololearn.com/W0A118A0a53a Thank you so much, Renu.

26th Mar 2021, 11:34 PM
Jojo
Jojo - avatar
2 Answers
+ 3
The following change works like you describe. The image gets hidden by the black hamburger menu items but will appear if there is space below the items. Is that enough or do you want the image completely hidden if any menu items appear? This is the new CSS snippet: .header .menu a { text-align: center; background-color: black; } /* make sure menu overlaps the home-content */ .header .menu { position:relative; z-index: 3;/*must be larger than home-content's z-index */ } This is a mix of my new snippet in the place I inserted: @media(max-width:1068px) { .logo { top:10px; left: 40px; font-size: 1.5rem; } .header .menu a { text-align: center; background-color: black; } /* make sure menu overlaps the home-content */ .header .menu { position:relative; z-index: 3;/*must be larger than home-content's z-index */ } } The position relative and z-index: 3 is important when the viewport is small enough that the white text and the menu items overlap each other.
27th Mar 2021, 6:14 AM
Josh Greig
Josh Greig - avatar
+ 1
Thank u so much Josh
28th Mar 2021, 8:41 PM
Jojo
Jojo - avatar