Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 6 months ago

CSS Grid, CSS Subgrid, Event Listeners, Transitions, Responsive Layout

Ayman Soliman•70
@aymansoliman-dev
A solution to the News homepage challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time? What I learned

I learned how to build a responsive hidden burger menu using HTML, CSS, and JavaScript. This involved using hidden elements, CSS positioning, CSS transitions for smooth animations, and JavaScript event listeners to toggle the menu's visibility by adjusting the menu's position on the workflow.

<img id="menu__icon" src="/assets/images/icon-menu.svg" alt="icon-menu" />
#menu {
  height: 100vh;
  width: 75vw;
  background: hsl(36, 100%, 99%);
  position: fixed;
  top: 0;
  transition: 0.5s ease-in-out;
  z-index: 2;
}

.hidden {
  right: -100%;
}

.visible {
  right: 0;
}
let menuIcon = document.getElementById("menu__icon");
menuIcon.addEventListener("click", () => {
  menu.classList.remove("hidden");
  menu.classList.add("visible");
});

iconMenuClose.addEventListener("click", () => {
  menu.classList.remove("visible");
  menu.classList.add("hidden");
});

Continued development

In future projects, I want to focus on responsively generated components. While I have learned how to create a burger menu, I want to refine my skills in dynamically generating and modifying UI elements based on screen size and user interactions.

Some key areas I plan to improve:

  • Dynamic Component Rendering: Creating elements in JavaScript based on user actions or device breakpoints.
  • CSS Flexibility: Enhancing my understanding of clamp(), min(), max(), and other modern CSS techniques for better responsiveness.
  • Performance Optimization: Ensuring that dynamically generated components do not negatively impact page load speed and user experience.
What challenges did you encounter, and how did you overcome them? Challenges I Encountered and How I Overcame Them

1. Toggling the Menu Visibility

  • Challenge: The menu needed to be hidden by default and only appear when the button was clicked.
  • Solution: I used display: none in CSS and toggled a class using JavaScript to show the menu.
.menu {
  display: none;
}

.menu.open {
  display: block;
}

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Ayman Soliman's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License