How to design a responsive menu only in HTML and CSS (No
JavaScript)?
In the previous tutorial we have completed the firststep(HTML) part of the responsive menu.
In this second step we you will focus on the design and
responsiveness of the menu.
So, once again go to your favorite editor( Notepad or
another one of your choice) and create a new file, name it style.css or
whatever name you prefer.
Make sure the file to be ended with .css extension otherwise
it won’t work.
Also, remember to save this file in the same directory where
your index.html file was saved, if you save it in another directory, you should
update the path of the style.css file in the index.html file.
Now, let’s div into the CSS code that beautify, arrange and
make the menu responsive.
Here is the code copy it and paste it the style.css file and
save the file once again:
<pre>
<code>
body{
margin:
0px;
padding:
0px;
}
nav{
position:
fixed;
margin-top:
0px;
padding-top:
0px;
width:
100%;
height:
75px;
background:
rgba(6,70,70,1.0);
box-shadow:
0px 4px 18px 0px rgba(6,70,70,1.0);
}
nav ul{
list-style-type:
none;
float:
right;
padding:
0px;
margin:
0px;
box-sizing:
border-box;
}
ul li{
float:
left;
margin-top:
8px;
margin-right:
8px;
-webkit-transition:background-color
1s ease 0.2s
}
ul li a{
display:
inline-block;
text-decoration:
none;
color:lightblue;
font-size:
2vw;
padding:
14px 16px;
}
nav ul li a:hover{
color:
white;
}
ul li a.active:link{
color:black;
}
#check{
display:
none;
}
.checkbutton{
float:
right;
font-size:
2vw;
color:
#fff;
cursor:
pointer;
display:
none;
}
nav .logo{
float:
left;
margin-top:10px;
margin-left:
2vw;
box-sizing:
border-box;
}
nav .logo p{
float:
left;
margin-top:10px;
font-size:
2.4vw;
color:
#fff;
letter-spacing:
1.5px;
text-transform:
uppercase;
font-weight:
bold;
box-sizing:
border-box;
text-shadow:5px
2px black;
}
div.header-menu{
position: fixed;
}
</code>
</pre>
Waww! Nice job you have created a nice responsive menu.
Alittle job at the end is to open index.html file in browser and look how it the menu that you have just created looks like.You have any question, please comment bellow or contact us on the contact page.
Comments