Responsive Dropdown Menu using only css | Sanwebcorner

Responsive Dropdown Menu using only css


In this post i am going to tell you how to create responsive Dropdown menu using only css without any javascript and jquery. This is one of the simple method because it made by using only css, The below image shows how the responsive menu looks like and also visit demo page to live preview the result of this program.

Now a days all are createed responsive website because it fits all the screens and also the mobile user increased day by day when comparing to the desktop users. So in website the main thing is to create responsive navigation, try this below example it helps to create responsive drop down menu. I hope this post will help you.


Html Code for Responsive Dropdown Menu


<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Dropdown responsive menu using only css</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<label for="responsive-button" class="responsive-button">Menu</label>
<input type="checkbox" id="responsive-button" role="button">
<nav class="san-menu">
<ul>
<li><a href="#">Menu1</a></li>
<li><a href="#">Menu2</a></li>
<li><a href="#">Menu3 <span class="san-menu-arrow">&#9660;</span></a>
<ul>
<li><a href="#">Drop-down Menu 3.1</a></li>
<li><a href="#">Drop-down Menu 3.2</a></li>
<li><a href="#">Drop-down Menu 3.3</a></li>
</ul>
</li>
<li><a href="#">Menu4</a></li>
<li><a href="#">Menu5</a></li>
<li><a href="#">Menu6 <span class="san-menu-arrow">&#9660;</span></a>
<ul>
<li><a href="#">Drop-down Menu 6.1</a></li>
<li><a href="#">Drop-down Menu 6.2</a></li>
<li><a href="#">Drop-down Menu 6.3</a></li>
<li><a href="#">Drop-down Menu 6.4</a></li>
</ul>
</li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</body>
</html>


Css Code for Responsive Dropdown Menu:

html, *
{
padding:0px;
margin:0px;
}


.san-menu, .san-menu ul, .san-menu ul li, .san-menu ul li a,
.san-menu ul ul, .san-menu ul ul li, .san-menu ul ul li a {
margin: 0;
padding: 0;
border: 0;
line-height: 1;
}

.san-menu ul {
list-style-type: none; 
text-align: center;
background-color: #0A7A32;

.san-menu ul li {
position: relative;
display: inline; 
text-align: center;
}

.san-menu ul li a {
text-decoration: none;
display: inline-block; 
padding: 15px 25px;
color: #ffffff;
background: #0A7A32;
}


.san-menu ul li a:hover, .san-menu ul li a:focus, .san-menu ul li a:active  {
color: #ffffff;
background: #0A692C;
}

.san-menu-arrow {
font-size: 10px;
}

.san-menu ul ul {
position: absolute;
display:none;
}


.san-menu ul li:hover ul {
display:block;
}


.san-menu ul ul li {
display: block;
text-align: left;
}


.san-menu ul ul li a {
width: 100%;
min-width:200px;
padding: 20px;
white-space: nowrap;
border-bottom: 1px solid #308E52;
color: #ffffff;
background: #3CB166;
}

.san-menu ul ul li a:hover, .san-menu ul ul li a:focus, .san-menu ul ul li a:active  {
color: #ffffff;
background: #0A692C;
}


.san-menu ul li a, .san-menu ul ul li, .san-menu ul li:hover, .san-menu ul ul {
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.responsive-button {
padding: 20px;
color: #ffffff;
font-weight: bold;
background: #105A2B;
border-bottom: 1px solid #308E52;
text-align: center;
display: none;
}

input[id=responsive-button] {
display: none;
}

input[id=responsive-button]:checked ~ .san-menu {
display: block;
}


@media screen and (max-width : 780px){

.responsive-button {
display: block;
}

.san-menu {
display: none;
}

.san-menu ul li {
display: block;
border-bottom: 1px solid #308E52;
}

.san-menu ul li, .san-menu ul li a {
width: 100%;
}

.san-menu ul ul {
position: relative;
display: none;
}

.san-menu ul li:hover ul {
display: block;
}

.san-menu ul ul li {
text-align: center;
}

}



Post a Comment

Labels

360 degree view product image 3d rotate 3d text 3step-form Accordion menu ajax All Browsers Animated Background Gradient animation audio controller auto complete Best accordion menu bootstrap border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll create random number Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed email otp verification email verifier Embed eventlist Expanding Menu feedbck form flash news section close button full screen menu Google custom search Google Maps Google reCAPTCHA Google site search gradient hide menu Horizontal News ticker Hover Htm Html html dropdown html form html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript Jquery js Layered image effect on mouse hover lock & unlock page scroll marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form Multi-Step-form mysql News ticker on hover change text to image our team page password generator password strength checker Photoshop PHP populate html selectbox Popup image on click the link pure css Question type form random number generate Random password Redirect page Based on the select box while submit the form responsive responsive menu responsive popup box Responsive Vertical Time line design rotate image selectbox based on select box simple coming soon page simple countdown based on end date simple typing effect slider sliding tab sms otp login statistic counter on scroll switch tag shape team member Time picker toggle toggle view transparent button underline animation up down slide validation vertical fixed sidebar Webtips Youtube