css grid menu

How we can create a menu with a grid layout using HTML CSS? Solution: CSS Grid Menu Layout With Display Flex, Which is a Responsive Grid Design.

I am sure that you know what is CSS Grid, & almost every designer or developer knows how to create girds. Using CSS grid and flex properties, the easiest point is making an object responsive. Nowadays the grid-based menu is on trend, Many creative developers now choose a grid-based menu over simple navbar.

Yesterday, I was surfing some personal websites, Then I saw a menu with grid view. Believe me, I feel these types of the menu is more attractive than a list type menu. If you want to make your website simple and fast, then don’t use this. Otherwise, you can use this to make your website more good looking.

Now the question is how to create the menu? Don’t worry, because today I am sharing CSS Grid Menu Layout Using Display Flex. In other words, I am sharing a Responsive Grid Based Menu Design. I added using display flex because I am also using it along with grid property. & it is also responsive, means it fits on every screen sizes.

If you are thinking now how this menu actually is, then see the preview given below.

Preview Of Responsive Grid Layout

See this video preview to getting an idea of how this menu looks like.

Now you can see this visually. If you like this, then get the source code of its.

You May Also Like:

CSS Grid Menu Source Code

As always, Before sharing source code let’s talk about it. As you know I got inspiration from a personal portfolio website to creating this. Actually, I created a clone of that website’s menu, sadly I forget the websites name. I used HTML CSS and JavaScript to create this menu.

Actually, JavaScript has a very small part of this menu. I used JavaScript to just create a toggle button, nothing else. Left all is based on Pure CSS and of course HTML also. All we know that we can’t create a webpage without HTML.

First I created Button using HTML and put two class, one for styling and one for creating a toggle effect.

That’s how the buttons HTML looks like. I used “+” sign on button, you can also use external icons like font-awesome.  After click on plus button its rotate on 765 deg. For creating the line effect on hover I used :before property. At before section, I created a blank content with 3px width, bottom:20px; and transform-origin: bottom; property. After positioning and alignment, the final line you can see on the video.

I used display: grid; property only in the main div. Inside the main div, I created 5 divs with class= "mainn-menu"  And inside the maiin-menu div, I create another div with class = "content". In content section I used display: flex; property.

For placing Image I put background-image property by selecting .maiin-menu:nth-child .  & I used @media for creating it responsive. Basically, for the responsive design, I change the grid’s width value (get info), that’s all. You can fully understand after getting the code.

For creating this you have to create 3 files. First for HTML, second for CSS, and third for JavaScript. Follow the steps to creating this without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes.

function.js

The final step, Create a JS file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created CSS Grid Menu With Display Flex, a Responsive Grid Menu. If you have any doubt or question comment down below.

Thanks For Visiting, Keep Visiting.

5 COMMENTS

  1. Bhai where do you learn all this? It just looks easy. But when comes to implementing, its not easy.
    How do you get such ideas?
    And that too at this frequency that after every single day, there is something to see from you?

    • If you want to create it without button, then there is no need for JavaScript. Just create a div and visible grids on hover.

      • what does “visible grids on hover” mean?

        I have tried to get rid of the javascript and wrap all else in a div container. Seems there is more to it. Do you have an example of “visible grids on hover?”

LEAVE A REPLY

Please enter your comment!
Please enter your name here