unable to centralize dropdownmenu using CSS - css

I know there are many posts on centralizing a drop down menu. However, after trying all the various solutions, it seems that I'm still missing something. I got the code of a dropdownmenu from some free website as follows:
#nav {
margin: 0;
padding: 7px 6px 0;
line-height: 100%;
border-radius: 2em;
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
background: #000080; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3090C7', endColorstr='#000080'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#3090C7), to(#000080)); /* for webkit browsers */
background: -moz-linear-gradient(top, #3090C7, #000080); /* for firefox 3.6+ */
border: solid 1px #6d6d6d;
}
#nav li
{
margin: 0 5px;
padding: 0 0 8px;
float: left;
position: relative;
list-style: none;
}
/* main level link */
#nav a {
font-weight: bold;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 8px 20px;
margin: 0;
-webkit-border-radius: 1.6em;
-moz-border-radius: 1.6em;
text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
/* main level link hover */
#nav .current a, #nav li:hover > a {
background: #d1d1d1; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ebebeb', endColorstr='#a1a1a1'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#a1a1a1)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ebebeb, #a1a1a1); /* for firefox 3.6+ */
color: #444;
border-top: solid 1px #f8f8f8;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
/* sub levels link hover */
#nav ul li:hover a, #nav li:hover li a {
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#nav ul a:hover {
background: #0399d4 !important; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#04acec', endColorstr='#0186ba'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba)) !important; /* for webkit browsers */
background: -moz-linear-gradient(top, #04acec, #0186ba) !important; /* for firefox 3.6+ */
color: #fff !important;
-webkit-border-radius: 0;
-moz-border-radius: 0;
text-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
/* level 2 list */
#nav ul {
background: #ddd; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#cfcfcf'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#cfcfcf)); /* for webkit browsers */
background: -moz-linear-gradient(top, #fff, #cfcfcf); /* for firefox 3.6+ */
display: none;
margin: 0;
padding: 0;
width: 185px;
position: absolute;
top: 35px;
left: 0;
border: solid 1px #b4b4b4;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
/* dropdown */
#nav li:hover > ul {
display: block;
}
#nav ul li {
float: none;
margin: 0;
padding: 0;
}
#nav ul a {
font-weight: normal;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
}
/* level 3+ list */
#nav ul ul {
left: 181px;
top: -3px;
}
/* rounded corners for first and last child */
#nav ul li:first-child > a {
-webkit-border-top-left-radius: 9px;
-moz-border-radius-topleft: 9px;
-webkit-border-top-right-radius: 9px;
-moz-border-radius-topright: 9px;
}
#nav ul li:last-child > a {
-webkit-border-bottom-left-radius: 9px;
-moz-border-radius-bottomleft: 9px;
-webkit-border-bottom-right-radius: 9px;
-moz-border-radius-bottomright: 9px;
}
/* clearfix */
#nav:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#nav {
display: inline-block;
margin-left: 15%;
margin-top: 20px;
}
html[xmlns] #nav {
display: block;
}
* html #nav {
height: 1%;
}
I tried to embed the menu with div having style of using margin-left and margin-right as auto but it still could not work probably due to the use of float:left.
Sorry if it this question seems repeated. I'm still new to CSS so I hope some kind soul can help me out here! Thanks!

Try:
#nav {
margin: 0;
}
#menu {
text-align: center;
}
Your updated fiddle.

not sure what the desired effect is, but using your #menu style, you can move that nav wherever you want:
#menu {
width:600px;
height:50px;
background-color:red;
padding-left:10px;
}
I just did a background color so you can see where your nav is in relation to the div. Post any other HTML you have so I can make changes if this isn't what you want.

Related

css deformed submenu second option and z-index

I'm creating a submenu for my website but it needs some little fixes.
First, I can't make the z-index work, is displayed under the content div, in the live example I removed all z-index, and righ now, I really have no idea how this works :(
Second, in the submenu from second option, the box is more large than the first one. I'm trying to fix it but I don't see where the problem is.
/* Sub-menu */
#main-nav ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
/* rounded corner */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
#main-nav ul li {
float: none;
display: block;
/* box shadow */
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 1px rgba(0, 0, 0, .4);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 1px rgba(0, 0, 0, .4);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 1px rgba(0, 0, 0, .4);
/* rounded corner */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
#main-nav ul li:last-child {
box-shadow: none;
}
#main-nav ul a {
color: #fff;
background: #474747;
display: block;
white-space: nowrap;
}
#main-nav ul a:hover {
/* gradient */
background: #6a6a6a url(images/nav-bar-bg.png) repeat-x;
background: -webkit-gradient(linear, left top, left bottom, from(#b9b9b9), to(#6a6a6a));
background: -moz-linear-gradient(top, #b9b9b9, #6a6a6a);
background: linear-gradient(-90deg, #b9b9b9, #6a6a6a);
background-image: linear-gradient(-90deg, #cdcdcd, #797979);
}
#main-nav ul li:first-child a {
/* rounded corner */
-webkit-border-radius: 8px 8px 0 0;
-moz-border-radius: 8px 8px 0 0;
border-radius: 8px 8px 0 0;
}
#main-nav ul li:last-child a {
/* rounded corner */
-webkit-border-radius: 0 0 8px 8px;
-moz-border-radius: 0 0 8px 8px;
border-radius: 0 0 8px 8px;
}
#main-nav ul li:first-child a:after {
content:'';
position: absolute;
left: 30px;
top: -8px;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #444;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #fafafa;
}
#main-nav:after {
visibility: hidden;
display: block;
font-size: 0;
content:" ";
clear: both;
height: 0;
}
Here's a live example: http://jsfiddle.net/y59kjsLn/1/
Thanks in advance!
Edit: add more css
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
.clearfix { display: block; zoom: 1; }
Chan this cause the z-index problem?
Edit2: Add the html code
Hmmm maybe has something to do with...
<div id="content">
<article class="post clearfix">
<?php
if(array_key_exists($matches[1], $includes)) {
$content = include($includes[$matches[1]]);
} else header("Location: /home");
?>
</article>
</div>
This is just behind the menu.
#content CSS code:
#content {
opacity: 0.8;
background: #fff;
margin: 30px 0 30px;
padding: 20px 35px;
width: 600px;
float: left;
/* rounded corner */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
/* box shadow */
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,.4);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,.4);
box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
#content .error {
color: red;
text-align: center;
}
#content .note {
font-size: 80%;
text-align: center;
}
#content p {
margin-top: 30px;
}
h2.post-title {
margin-top: 15px;
background: #888;
border-radius: 5px;
padding: 0px 5px ;
border-top: 1px solid #889;
border-bottom: 1px solid #889;
text-align: center;
}
h2.post-title a {
color: #FFFFFF;
font-size: 0.9em;
text-shadow: 1px 1px 2px #333333;
}
.post {
margin-bottom: 20px;
}
.post-title {
margin: 0 0 5px;
padding: 0;
font: bold 26px/120% Arial, Helvetica, sans-serif;
}
.post-title a {
text-decoration: none;
color: #000;
}
.post-meta {
margin: 0 0 10px;
font-size: 90%;
}
figure.post-imagen img {
float: left;
margin: 5px;
max-width: 260px;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
.clearfix { display: block; zoom: 1; }
Js Fiddle
removed the margin which was affecting the sub menu
#main-nav li:first-child {
margin-left: 10px;
}
edit
Remove and Add
#content
opacity: 0.8; /* removed */
background: rgba(255, 255, 255, 0.55); /* added */
}

adjusting css width for customized drop down box

Here is drop down box I got to work for me.
But it goes outof boundry on left end. Actually menu items should fit exactly below the text box.
Check Fiddle
I tried changing width of all element but could not set it. Can some one tell me which class exactly controls width of menu item which appear when dropdown box is popped?
css:
.container {
width:90%;
margin:10% auto;
}
.dropdown-menu{
width:85%;
margin:0 auto;
}
.twitter-typeahead .tt-query, .twitter-typeahead .tt-hint {
margin-bottom: 0;
width: 360px; !important;
}
.twitter-typeahead .tt-hint {
display: block;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
border: 1px solid transparent;
border-radius:4px;
}
.twitter-typeahead .hint-small {
height: 30px;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
line-height: 1.5;
}
.twitter-typeahead .hint-large {
height: 45px;
padding: 10px 16px;
font-size: 18px;
border-radius: 6px;
line-height: 1.33;
}
.tt-dropdown-menu {
min-width: 260px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, .2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.tt-suggestion {
display: block;
padding: 3px 20px;
}
.tt-suggestion.tt-is-under-cursor {
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
}
.tt-suggestion.tt-is-under-cursor a {
color: #fff;
}
.tt-suggestion p {
margin: 0;
}
On your class .dropdown-menu add this:
.dropdown-menu{
width:360px;
left:auto;
margin:0 auto;
}
The Fiddle demo
It's because 360px is the size of your input .twitter-typeahead .tt-query, .twitter-typeahead .tt-hint.
And the left:auto to keep the original distance no matter the absolute position.

CSS - how do i stretch the background of the menu

Hello,
Can someone help me, how can i stretch the background of the menu (to be full width, from left to right)?
I'm a beginner.
Thanks.
#menu, #menu ul {
margin: 0;
padding: 0;
list-style: none;
}
#menu {
width:100%;
margin: 0px;
background-color: #3d56ac;
background-image: linear-gradient(#444, #111);
}
#menu:before,
#menu:after {
content: "";
display: table;
}
#menu:after {
clear: both;
}
#menu {
zoom:1;
}
#menu li {
float: left;
border-right: 1px solid #222;
box-shadow: 1px 0 0 #444;
position: relative;
}
#menu a {
float: left;
padding: 12px 30px;
color: #FFF;
text-transform: uppercase;
font: bold 12px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 1px 0 #111;
}
#menu li:hover > a {
color: #fafafa;
}
*html #menu li a:hover { /* IE6 only */
color: #fafafa;
}
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
z-index: 1;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
border-radius: 3px;
transition: all .2s ease-in-out;
}
#menu li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
#menu ul ul {
top: 0;
left: 150px;
margin: 0 0 0 20px;
_margin: 0; /*IE6 only*/
box-shadow: -1px 0 0 rgba(255,255,255,.3);
}
#menu ul li {
float: none;
display: block;
border: 0;
_line-height: 0; /*IE6 only*/
box-shadow: 0 1px 0 #111, 0 2px 0 #666;
}
#menu ul li:last-child {
box-shadow: none;
}
#menu ul a {
padding: 10px;
width: 130px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a:hover {
background-color: #0186ba;
background-image: linear-gradient(#04acec, #0186ba);
}
#menu ul li:first-child > a {
border-radius: 3px 3px 0 0;
}
#menu ul li:first-child > a:after {
content: '';
position: absolute;
left: 40px;
top: -6px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #444;
}
#menu ul ul li:first-child a:after {
left: -6px;
top: 50%;
margin-top: -6px;
border-left: 0;
border-bottom: 6px solid transparent;
border-top: 6px solid transparent;
border-right: 6px solid #3b3b3b;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #04acec;
}
#menu ul ul li:first-child a:hover:after {
border-right-color: #0299d3;
border-bottom-color: transparent;
}
#menu ul li:last-child > a {
border-radius: 0 0 3px 3px;
}
This should work:
#menu {
background-size: 100%;
}
You need to fix the width of the image... if your want to Stretch the background image...
**CSS**
background-image: url("menu.png");
background-size: 875px 125px;
background-repeat: no-repeat;
Hope this will helps you...
or you can try...
/css
body{margin: 0 auto;}
.menu100percent {
background: #3584b4; /* Old browsers */
background: -moz-linear-gradient(top, #3584b4 0%, #25567f 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#3584b4), color-stop(100%,#25567f)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #3584b4 0%,#25567f 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #3584b4 0%,#25567f 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #3584b4 0%,#25567f 100%); /* IE10+ */
background: linear-gradient(to bottom, #3584b4 0%,#25567f 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3584b4', endColorstr='#25567f',GradientType=0 ); /* IE6-9 */
color: white;
font-size: 16px;
height: 37px;
width:100%;
}
.menu{width:1000px; margin: 0 auto; }
.menu a{color:#fff; font-size:12px; line-height:37px; font-family:Arial; text-decoration:none;}
/html
<div class="menu100percent">
<div class="menu">
Shop
</div>
</div>
DEMO HERE

how to modify touch events for a custom app-ios button

I'm trying add hover, active state to custom back button. custom data-theme is "app-ios" Here is the
`
<div data-role="page" id="main">
<div data-theme="c" data-role="header">
<h3>
Header
</h3>
<a data-role="button" data-rel="back" data-icon="arrow-l" data-theme="app-ios">Back</a>
</div>
<div data-role="content"></div
</div>
`
CSS
/* button background and borders color */
a[data-theme="app-ios"] {
border: none;
}
a[data-theme="app-ios"] .ui-btn-corner-all {
border: 1px solid rgba(0,0,0, 0.4);
-webkit-border-radius: 5px;
background: #ba2669; /* Old browsers */
-webkit-box-shadow: 0 1px 0 rgba(255,255,255, 0.25), inset 0 1px 1px rgba(0,0,0, 0.2);
overflow: visible;
padding-left: 8px !important;
padding-right: 8px !important;
}
/* shadows and label color */
/* button background and borders color */
a[data-theme="app-ios"] {
border: none;
}
a[data-theme="app-ios"] .ui-btn-corner-all {
border: 1px solid rgba(0,0,0, 0.4);
-webkit-border-radius: 5px;
background: #ba2669;
-webkit-box-shadow: 0 1px 0 rgba(255,255,255, 0.25), inset 0 1px 1px rgba(0,0,0, 0.2);
overflow: visible;
padding-left: 8px !important;
padding-right: 8px !important;
}
/* shadows and label color */
a[data-theme="app-ios"].ui-shadow,
a[data-theme="app-ios"] {
box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none;
background-clip: none; -webkit-background-clip: none; -moz-background-clip: none;
color: white;
font-weight: bold;
font-size: 12px!important;
text-transform: uppercase;
top: 5px;
text-decoration: none;
text-shadow: 0 -1px 0 rgba(0,0,0, 0.4);
width: 51px;
}
/* make room for the point */
a[data-theme="app-ios"].ui-btn-left {
left: 14px;
}
a[data-theme="app-ios"].ui-btn-left .ui-btn-corner-all {
padding-left: 5px !important;
}
/* position the DIV that contains the point */
a[data-theme="app-ios"] .ios-tip {
float: left;
left: -10px;
top: 6px;
position: absolute;
-webkit-transform: scale(.7, 1.0);
}
/* apply gradient */
a[data-theme="app-ios"] .ios-tip span {
display: block;
width: 19px;
height: 18px;
border: 2px solid rgba(0,0,0, 0.4);
border-right: 0;
border-top: 0;
/* the gradient color mus be slightly different since the point is within the body of the button */
background: #ba2669; /* Old browsers */
border-radius: 1px; -webkit-border-radius: 1px; -moz-border-radius: 1px;
/*box-shadow: 0 1px 0 rgba(255,255,255, 0.25); -webkit-box-shadow: 0 1px 0 rgba(255,255,255, 0.25); -moz-box-shadow: 0 1px 0 rgba(255,255,255, 0.25);*/
-webkit-transform: rotate(45deg) scale(.9, .9);
}

Drop down menu to hide on click event

Question
How do I hide my menu on a click event
Background
I am using a pure CSS3 menu in a single page application. It works well.
body {
font: normal .8em/1.5em Arial, Helvetica, sans-serif;
background: #ebebeb;
width: 900px;
margin: 100px auto;
color: #666;
}
a {
color: #333;
}
#nav {
margin: 0;
padding: 7px 6px 0;
line-height: 100%;
border-radius: 2em;
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
background: #8b8b8b; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#a9a9a9', endColorstr='#7a7a7a'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#a9a9a9), to(#7a7a7a)); /* for webkit browsers */
background: -moz-linear-gradient(top, #a9a9a9, #7a7a7a); /* for firefox 3.6+ */
border: solid 1px #6d6d6d;
}
#nav li {
margin: 0 5px;
padding: 0 0 8px;
float: left;
position: relative;
list-style: none;
}
/* main level link */
#nav a {
font-weight: bold;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 8px 20px;
margin: 0;
-webkit-border-radius: 1.6em;
-moz-border-radius: 1.6em;
text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
/* main level link hover */
#nav .current a, #nav li:hover > a {
background: #d1d1d1; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ebebeb', endColorstr='#a1a1a1'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#a1a1a1)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ebebeb, #a1a1a1); /* for firefox 3.6+ */
color: #444;
border-top: solid 1px #f8f8f8;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
/* sub levels link hover */
#nav ul li:hover a, #nav li:hover li a {
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#nav ul a:hover {
background: #0399d4 !important; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#04acec', endColorstr='#0186ba'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba)) !important; /* for webkit browsers */
background: -moz-linear-gradient(top, #04acec, #0186ba) !important; /* for firefox 3.6+ */
color: #fff !important;
-webkit-border-radius: 0;
-moz-border-radius: 0;
text-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
/* level 2 list */
#nav ul {
background: #ddd; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#cfcfcf'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#cfcfcf)); /* for webkit browsers */
background: -moz-linear-gradient(top, #fff, #cfcfcf); /* for firefox 3.6+ */
display: none;
margin: 0;
padding: 0;
width: 185px;
position: absolute;
top: 35px;
left: 0;
border: solid 1px #b4b4b4;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
/* dropdown */
#nav li:hover > ul {
display: block;
}
#nav ul li {
float: none;
margin: 0;
padding: 0;
}
#nav ul a {
font-weight: normal;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
}
/* level 3+ list */
#nav ul ul {
left: 181px;
top: -3px;
}
/* rounded corners for first and last child */
#nav ul li:first-child > a {
-webkit-border-top-left-radius: 9px;
-moz-border-radius-topleft: 9px;
-webkit-border-top-right-radius: 9px;
-moz-border-radius-topright: 9px;
}
#nav ul li:last-child > a {
-webkit-border-bottom-left-radius: 9px;
-moz-border-radius-bottomleft: 9px;
-webkit-border-bottom-right-radius: 9px;
-moz-border-radius-bottomright: 9px;
}
/* clearfix */
#nav:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#nav {
display: inline-block;
}
html[xmlns] #nav {
display: block;
}
* html #nav {
height: 1%;
}
CSS3 Dropdown Menu by Web Designer Wall
Assuming your question is "what do I need to do with the Javascript?", one of the easiest ways to hide the dropdown is to use a framework, such as jQuery. Using jQuery allows you to write something like (untested):
$('#parent_li').click(function(){
$('#child_li').slideToggle('slow');
});
Which will toggle the visibility state of the list item's child list. In this case, using a slow slide animation, but there are other animation types you can use.
Kindly check if the below link helps
<nav role="navigation">
<div id="menuToggle">
<!--
A fake / hidden checkbox is used as click reciever,
so you can use the :checked selector on it.
-->
<input type="checkbox" />
<span></span>
<span></span>
<span></span>
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Info</li>
<li>Contact</li>
<a href="https://erikterwan.com/" target="_blank"><li>Show me more</li>
</a>
</ul>
</div>
</nav>
https://codepen.io/erikterwan/pen/EVzeRP

Resources