Simple CSS Dropdown Menu

Developer
Size
3,822 Kb
Views
24,288

How do I make an simple css dropdown menu?

Nav bar with dropdown menu with CSS transitions & icons via an icon font.. What is a simple css dropdown menu? How do you make a simple css dropdown menu? This script and codes were developed by James Barnett on 11 August 2022, Thursday.

Simple CSS Dropdown Menu Previews

Simple CSS Dropdown Menu - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple CSS Dropdown Menu</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ @import url(http://weloveiconfonts.com/api/?family=entypo);
/*reset*/ul{list-style:none;}a{text-decoration:none;}ul,li,a{margin:0;padding:0;}
/***** basic styles *****/
body { background: #E0E0E0 url('http://subtlepatterns.com/patterns/creampaper.png');}
.container { position: relative; width: 800px; margin: 30px auto;
}
.nav-container { width: 650px; margin: 0 100px;
}
p { font-family: Georgia; color: #333;
}
a { font-family: 'Helvetica', 'Arial', san-serif; color: #333;
}
/***** menu *****/
#navmenu { display: inline-block; height: 30px; padding: 5px 0; border: solid 1px #A3A3A3; border-radius: 7px; box-shadow: 2px 2px 5px #ccc;
}
#navmenu > li { border-color: #ADADAD; border-right: solid 1px #A3A3A3; padding: 0 10px;
}
#navmenu li { float: left; position: relative; line-height: 30px; /* must match height of ul */
}
#navmenu li:hover span { color: #C89292; }
.nav-link { display: inline; margin: 0 10px 0 50px;
}
/* icon font */
[class*="entypo-"] { font-family: 'Entypo', sans-serif; }
#navmenu span[class*="entypo-"] { position: absolute; left: 15px; color: #8f8f8f; font-size: 1.5em;
}
/***** submenu *****/
/* submenu container */
#drop { opacity: 0; position: absolute; top: 35px; left: 0px; width: 150px; background: #333;
}
/* submenu links */
#drop li a { background: #333; color: #E0E0E0; font-size: 0.8em; margin-left: 10px;
}
/* height of submenu links */
#navmenu li:hover ul li { height: 30px; line-height: 30px;
}
/* submenu positioning */
#navmenu li:hover ul { opacity: 1; }
#drop li { float: none; position: static; height: 0; line-height: 0; background: none;
}
/* submenu transitions */
#navmenu li { transition: all 0.2s; }
#navmenu li a { transition: all 0.5s; }
#drop { transition: all 1s; }
#drop li { transition: height 0.5s; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class = "container"> <div class = "nav-container"> <ul id="navmenu"> <li><a href="#"><span class = "entypo-home"></span><span class = "nav-link">Home</span></a></li> <li><a href="#"><span class = "entypo-lamp"></span><span class = "nav-link">About</span></a></li> <li><a href="#" id = "submenu"><span class = "entypo-book-open"></span><span class = "nav-link">Products</span></a> <ul id = "drop" > <li><a href="#">Widgets</a></li> <li><a href="#">Thingamabobs</a></li> <li><a href="#">Doohickies</a></li> </ul> </li> <li><a href="#"><span class = "entypo-mail"></span><span class = "nav-link"> Contact</span></a></li> </ul> </div> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Simple CSS Dropdown Menu - Script Codes CSS Codes

@import url(http://weloveiconfonts.com/api/?family=entypo);
/*reset*/ul{list-style:none;}a{text-decoration:none;}ul,li,a{margin:0;padding:0;}
/***** basic styles *****/
body { background: #E0E0E0 url('http://subtlepatterns.com/patterns/creampaper.png');}
.container { position: relative; width: 800px; margin: 30px auto;
}
.nav-container { width: 650px; margin: 0 100px;
}
p { font-family: Georgia; color: #333;
}
a { font-family: 'Helvetica', 'Arial', san-serif; color: #333;
}
/***** menu *****/
#navmenu { display: inline-block; height: 30px; padding: 5px 0; border: solid 1px #A3A3A3; border-radius: 7px; box-shadow: 2px 2px 5px #ccc;
}
#navmenu > li { border-color: #ADADAD; border-right: solid 1px #A3A3A3; padding: 0 10px;
}
#navmenu li { float: left; position: relative; line-height: 30px; /* must match height of ul */
}
#navmenu li:hover span { color: #C89292; }
.nav-link { display: inline; margin: 0 10px 0 50px;
}
/* icon font */
[class*="entypo-"] { font-family: 'Entypo', sans-serif; }
#navmenu span[class*="entypo-"] { position: absolute; left: 15px; color: #8f8f8f; font-size: 1.5em;
}
/***** submenu *****/
/* submenu container */
#drop { opacity: 0; position: absolute; top: 35px; left: 0px; width: 150px; background: #333;
}
/* submenu links */
#drop li a { background: #333; color: #E0E0E0; font-size: 0.8em; margin-left: 10px;
}
/* height of submenu links */
#navmenu li:hover ul li { height: 30px; line-height: 30px;
}
/* submenu positioning */
#navmenu li:hover ul { opacity: 1; }
#drop li { float: none; position: static; height: 0; line-height: 0; background: none;
}
/* submenu transitions */
#navmenu li { transition: all 0.2s; }
#navmenu li a { transition: all 0.5s; }
#drop { transition: all 1s; }
#drop li { transition: height 0.5s; }

Simple CSS Dropdown Menu - Script Codes JS Codes

// CSS Styling by me
// Dropdown menu code from:
// http://www.gethifi.com/blog/nicer-navigation-with-css-transitions
//Allow clicking instead of hover for the dropdown menu
$(document).ready( function(){ $('#submenu').click( function(event){ event.stopPropagation(); $('#drop').toggle(); }); $(document).click( function(){ $('#drop').hide(); });
});
Simple CSS Dropdown Menu - Script Codes
Simple CSS Dropdown Menu - Script Codes
Home Page Home
Developer James Barnett
Username jamesbarnett
Uploaded August 11, 2022
Rating 3.5
Size 3,822 Kb
Views 24,288
Do you need developer help for Simple CSS Dropdown Menu?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

James Barnett (jamesbarnett) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!