background on ul to wrap the height of the tallest child? - html

I know there have been a lot of similar questions but none of the solutions worked for me. the predominant answer was to have overflow: hidden; on the ul but that's no good for me because the way i have overflow coded is essential for the menu and its transitions.
essentially i have a 2 column drop-down menu. the left column is the submenu list, the right column is an image. each main menu item has a different number of submenu items and sometimes even less than the height of the img. i want to fill the background of the ul class="twinsub" but i can't get it to pick up same as the height of the tallest list whether that be the image or the submenu list. i have tried everything i can think of with no success.
here are a couple of images to illustrate what i am trying to do:
here is the code:
Updated JS FIDDLE
HTML:
<section id="menuWrapper">
<nav id="menu" class="cf" role="navigation">
<!-- Main Nav Start -->
<ul id="main-nav" class="clearfix">
<!----------------------------------------- Solutions ------------------>
<li id="technology" class="parent menu-item">Solutions
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="solutions-turnkey" class="menu-item">Turnkey Development
</li>
<li id="solutions-financing" class="menu-item">Financial Modeling
</li>
<li id="solutions-execution" class="menu-item">World-Class Execution
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</li>
<li id="technology" class="parent menu-item">Services
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="services-devlopment" class="menu-item">Development & Financing
</li>
<li id="services-design" class="menu-item">Design & Engineering
</li>
<li id="services-construction" class="menu-item">Construction & Procurement
</li>
<li id="services-operations" class="menu-item">Operations & Maintenance
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</li>
</ul>
</nav>
CSS:
#menu {
display:inline-block;
clear:both;
height:auto;
}
#menu ul {
margin:0;
}
#menu li {
float:left;
position:relative;
}
#menu > ul > li > a {
display:block;
line-height: .4em;
}
/* Submenu (second level) */
#menu li > ul {
position:absolute;
top:auto;
left:0;
width:180px;
max-height:0;
visibility: hidden;
z-index:99999;
overflow:hidden;
}
#menu ul li:hover ul {
visibility: visible;
max-height: 330px;
width: 204px;
overflow: visible;
}
#menu ul li > ul:hover {
overflow:visible;
}
#menu li > ul li {
height:36px;
width:100%;
}
#menu li > ul li:last-child {
height: 35px;
}
#menu li > ul li a {
padding: 11px 15px;
height: 35px;
color: #FFF;
width: 100%;
display: block;
}
ul.twinsub {
clear: both;
display: inline-block;
width:408px !important;
border-right: none !important;
background-color: #5d6f82 !important;
overflow: hidden;
}
ul.twinsub > li {
display: inline-block;
border-top: none !important;
background: #FFF;
line-height: 38px;
}
li.twinmultisub {
display: block;
width: 50% !important;
}
.menuimage {
width: 100% !important;
margin-left: 1px;
border-right: none;
}
li.twinimg {
float: left;
border: none;
}
li.twinleft {
clear: both;
float: left;
border-right: none !important;
}
li.twinheader {
width: 50% !important;
text-align: left;
padding-left: 14px;
font-size: .9em;
background-color: #5d6f82 !important;
color: #FFF;
opacity: 1;
}

How about adding a wrapping div around the inner ul, and add a background color to that one.
This example should make a good beginning
.wrapp {
background: #13385F;
}
body {
margin: 0;
overflow-x: hidden;
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
a {
background: transparent;
text-decoration: none;
}
a:active, a:hover {
outline: 0;
}
nav ul, nav ol {
list-style: none;
list-style-image: none;
margin: 0;
padding: 0;
}
h1, h2, h3, h4 {
margin: 0;
padding: 0;
border: 0;
vertical-align:baseline;
font-family:'Open Sans', sans-serif;
}
* {
box-sizing:border-box;
-moz-box-sizing:border-box;
}
#menu a {
text-decoration: none;
}
#menuWrapper {
display: block;
text-align: center;
margin: 15px auto 15px;
}
#menu {
display:inline-block;
clear:both;
height:auto;
-webkit-box-shadow: 0px 9px 10px -9px rgba(35, 35, 35, 0.8);
-moz-box-shadow: 0px 9px 10px -9px rgba(35, 35, 35, 0.8);
box-shadow: 0px 9px 10px -9px rgba(35, 35, 35, 0.8);
}
#menu ul {
margin:0;
}
#menu li {
float:left;
position:relative;
}
#menu > ul > li > a {
padding:25px 19px 20px;
border-bottom:3px solid transparent;
margin-right:0px;
color:#6D6E70;
font: 1em'Open Sans', sans-serif;
font-weight:bold;
text-align:center;
text-transform: uppercase;
display:block;
line-height: .4em;
}
#menu > ul > li:last-child > a {
font-size: 1em;
}
#menu > ul > li:hover > a {
color:#5999db;
border-bottom: 3px solid #5999db;
}
#menu > ul li.selected > a, #menu > ul li.selected:hover > a {
color:#3F9944;
border-color:#FFF100;
}
/* Submenu (second level) */
#menu li > .wrapp > ul {
position:absolute;
top:auto;
left:0;
width:180px;
max-height:0;
/* -webkit-box-shadow: 0px 2px 7px 1px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 0px 2px 7px 1px rgba(0, 0, 0, 0.4);
box-shadow: 0px 2px 7px 1px rgba(0, 0, 0, 0.4); */
visibility: none;
z-index:99999;
overflow:hidden;
-webkit-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-moz-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-o-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-ms-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
transition: max-height 0.2s ease, visibility 0s linear 0.5s;
background: inherit !important;
}
#menu ul li:hover ul {
visibility: visible;
max-height: 330px;
width: 204px;
transition-delay: 0s;
overflow: visible;
border: 1px solid #EEE;
border-top: 0;
}
#menu ul li > ul:hover {
overflow:visible;
}
#menu li > ul li {
height:36px;
width:100%;
border-bottom: 1px solid #EEE;
padding-top:0;
font-weight: 600;
background-color: #13385F;
color: #FFF;
opacity: 1;
}
#menu li > ul li:last-child {
border-bottom:none;
height: 35px;
}
#menu li > ul li a {
background: rgba(19, 57, 95, 0.3);
padding: 11px 15px;
height: 35px;
color: #FFF;
width: 100%;
font: 10px'Open Sans', sans-serif;
font-weight: bold;
text-align: left;
text-transform: uppercase;
display: block;
opacity: 1;
}
#menu li > ul li:hover > a {
color: #3B3B3B;
background: #5999db;
}
#menu li > ul li.selected > a, #menu li > ul li.selected:hover > a {
color: #3B3B3B;
background: #FFF;
}
ul.twinsub {
clear: both;
display: inline-block;
width:408px !important;
border-right: none !important;
background-color: #5d6f82 !important;
overflow: hidden;
}
ul.twinsub > li {
display: inline-block;
border-top: none !important;
background: #FFF;
line-height: 38px;
}
li.twinmultisub {
display: block;
width: 50% !important;
}
.menuimage {
width: 100% !important;
margin-left: 1px;
border-right: none;
line-height: 0 !important;
font-size: 0 !important;
}
li.twinimg {
float: left;
border: none;
}
li.twinimg section {
line-height: 0;
}
.borderleft {
border-left: 1px solid #EEE;
}
li.twinleft {
clear: both;
float: left;
border-right: none !important;
}
li.twinheader {
width: 50% !important;
text-align: left;
padding-left: 14px;
font-size: .9em;
background-color: #5d6f82 !important;
color: #FFF;
opacity: 1;
}
<section id="menuWrapper">
<nav id="menu" class="cf" role="navigation">
<!-- Main Nav Start -->
<ul id="main-nav" class="clearfix">
<!----------------------------------------- Solutions ------------------>
<li id="technology" class="parent menu-item">Solutions
<div class="wrapp">
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="solutions-turnkey" class="menu-item">Turnkey Development
</li>
<li id="solutions-financing" class="menu-item">Financial Modeling
</li>
<li id="solutions-execution" class="menu-item">World-Class Execution
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</div>
</li>
<li id="technology" class="parent menu-item">Services
<div class="wrapp">
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="services-devlopment" class="menu-item">Development & Financing
</li>
<li id="services-design" class="menu-item">Design & Engineering
</li>
<li id="services-construction" class="menu-item">Construction & Procurement
</li>
<li id="services-operations" class="menu-item">Operations & Maintenance
</li>
<li id="services-construction" class="menu-item">Construction & Procurement
</li>
<li id="services-operations" class="menu-item">Operations & Maintenance
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</div>
</li>
</ul>
</nav>
</section>
Just remeber to fix the css on the menu. And the section around the image, and the image itself needs a line-height of 0.

Related

CSS3 slide down menu on hover

I want to build a menu that is CSS only. No jQuery.
I've gotten this far but can't make the menu slide in from the top. Here's a fiddle (oddly enough, it doesn't look like my menu... but all the styles are there)
Some code: The HTML:
<div class="menu">
<ul>
<li class="blue"> <a style="text-decoration: none" href="/who-we-are">Who We Are</a>
</li>
<li class="red"> <a style="text-decoration: none" href="/services">Services</a>
<ul>
<li> Post 1
</li>
<li> Post 2
</li>
<li> Post 3
</li>
</ul>
</li>
<li class="orange"><a style="text-decoration: none" href="/packages">Packages</a>
<ul>
<li> Post 1
</li>
<li> Post 2
</li>
<li> Post 3
</li>
</ul>
</li>
<li class="green"><a style="text-decoration: none" href="/contact-us">Contact</a>
</li>
</ul>
</div>
And my CSS:
.menu {
float: left;
margin-top: 0px;
}
.blue, div.item.blue div {
color: #009dc4;
}
.red, div.item.red div {
color: #fe4f00;
}
.orange, div.item.orange div {
color: #ff5958;
}
.green, div.item.green div {
color: #50c402;
}
.menu ul li a {
display: block;
height: 45px;
padding-top: 18px;
}
.menu ul li a:visited {
color: inherit;
}
.menu ul {
list-style: none;
margin: 0;
}
.menu ul li {
display: inline-block;
position: relative;
cursor: pointer;
width: 145px;
font-family: Georgia;
height: 45px;
font-size: 20px;
line-height: 22px;
font-weight: bold;
padding-left: 5px;
margin-top: 0px;
margin-right: 46px;
border-bottom: 5px solid;
z-index: 5000;
}
.menu ul li:hover {
color: #ffffff !important;
}
.menu ul li.blue:hover {
background-color: #009dc4;
border-bottom: 5px solid #009dc4;
}
.menu ul li.red:hover {
background-color: #fe4f00;
border-bottom: 5px solid #fe4f00;
}
.menu ul li.orange:hover {
background-color: #ff5958;
border-bottom: 5px solid #ff5958;
}
.menu ul li.green:hover {
background-color: #50c402;
border-bottom: 5px solid #50c402;
}
.menu ul li ul {
display: none;
opacity: 0;
visibility: hidden;
position: absolute;
top: 45px;
}
.menu ul li ul li {
display: block;
font-size: 12px;
border-bottom: none;
width: 145px;
color: #ffffff;
padding-left: 0px;
height: 34px;
line-height: normal;
position: relative;
left: -5px;
}
.menu ul li ul li a {
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: normal;
height: auto;
padding: 10px 5px;
font-size: 12px;
background-color: #4fc7c1;
-webkit-transition: all 0.1s;
-moz-transition: all 0.1s;
-ms-transition: all 0.1s;
-o-transition: all 0.1s;
transition: all 0.1s;
}
.menu ul li ul li a:hover {
background: #a3edf5;
}
.menu ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
.menu > ul > li:last-of-type {
margin-right: 0px;
}
If someone can just help with getting the slide down to work, I'd appreciate it.
Unfortunately there is no way to animate height:0 to height:auto with CSS (as of CSS3). However there is a workaround using max-height documented here: http://css3.bradshawenterprises.com/animating_height/
With that logic I have created a simple example from your JS fiddle. All it does is set the css style max-height:0 on the drop-down <ul> element, some transitions for the max-height css attribute and then a large max-height value on menu hover.
Unfortunately the max-height must be hard-coded (cannot be auto) so we are limited here; but if you are confident that your menus will never exceed say 500px then you would simply put 500px.
Here's the fiddle:
http://jsfiddle.net/6ame5wcu/4/
All you need to do is to set max-height:0; and overflow:hidden; then add a transition on it like this:
.menu ul li ul {
max-height:0em;
overflow:hidden;
position: absolute;
top: 45px;
transition:max-height .9s ease
}
on :hover set a max-height ie max-height:600px;
.menu ul li:hover ul {
max-height:600px;
}
DEMO
Full code:
<div class="menu">
<ul>
<li class="blue"> Who We Are
</li>
<li class="red"> Services
<ul>
<li> Post 1
</li>
<li> Post 2
</li>
<li> Post 3
</li>
</ul>
</li>
<li class="orange">Packages
<ul>
<li> Post 1
</li>
<li> Post 2
</li>
<li> Post 3
</li>
</ul>
</li>
<li class="green">Contact
</li>
</ul>
</div>
css
a{text-decoration: none}
.menu {
float: left;
margin-top: 0px;
}
.blue, div.item.blue div {
color: #009dc4;
}
.red, div.item.red div {
color: #fe4f00;
}
.orange, div.item.orange div {
color: #ff5958;
}
.green, div.item.green div {
color: #50c402;
}
.menu ul li a {
display: block;
height: 45px;
padding-top: 18px;
}
.menu ul li a:visited {
color: inherit;
}
.menu ul {
list-style: none;
margin: 0;
}
.menu ul li {
display: inline-block;
position: relative;
cursor: pointer;
width: 145px;
font-family: Georgia;
height: 45px;
font-size: 20px;
line-height: 22px;
font-weight: bold;
padding-left: 5px;
margin-top: 0px;
margin-right: 46px;
border-bottom: 5px solid;
z-index: 5000;
}
.menu ul li:hover {
color: #ffffff !important;
}
.menu ul li.blue:hover {
background-color: #009dc4;
border-bottom: 5px solid #009dc4;
}
.menu ul li.red:hover {
background-color: #fe4f00;
border-bottom: 5px solid #fe4f00;
}
.menu ul li.orange:hover {
background-color: #ff5958;
border-bottom: 5px solid #ff5958;
}
.menu ul li.green:hover {
background-color: #50c402;
border-bottom: 5px solid #50c402;
}
.menu ul li ul {
max-height:0em;
overflow:hidden;
position: absolute;
top: 45px;
transition:max-height .9s ease
}
.menu ul li:hover ul {
max-height:600px;
}
.menu ul li ul li {
display: block;
font-size: 12px;
border-bottom: none;
width: 145px;
color: #ffffff;
padding-left: 0px;
height: 34px;
line-height: normal;
position: relative;
left: -5px;
}
.menu ul li ul li a {
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: normal;
height: auto;
padding: 10px 5px;
font-size: 12px;
background-color: #4fc7c1;
-webkit-transition: all 0.1s;
-moz-transition: all 0.1s;
-ms-transition: all 0.1s;
-o-transition: all 0.1s;
transition: all 0.1s;
}
.menu ul li ul li a:hover {
background: #a3edf5;
}
.menu > ul > li:last-of-type {
margin-right: 0px;
}

How to add dropdown menu?

I have an existing website with the menu code below and I want to add more stuff to my site but users need to nevigate to those pages please help me to add a sub menu in dropdown to the code I have. Please help?
HTML:
<!-- Header -->
<div id="header">
<div id="nav-wrapper">
<!-- Nav -->
<nav id="nav">
<ul>
<li class="active">Homepage</li>
<li>Left Sidebar</li>
<li>Right Sidebar</li>
<li>No Sidebar</li>
</ul>
</nav>
</div>
</div>
CSS:
#nav {
}
#nav-wrapper {
background: rgba(0,0,0,.1);
position: absolute;
top: 0;
left: 0;
width: 100%;
}
#nav > ul {
margin: 0;
padding: 0;
text-align: center;
}
#nav > ul > li {
display: inline-block;
border-right: 1px solid;
border-color: rgba(255,255,255,.1);
}
#nav > ul > li:last-child {
padding-right: 0;
border-right: none;
}
#nav > ul > li > a, #nav > ul > li > span {
display: inline-block;
padding: 1.5em 1.5em;
letter-spacing: 0.06em;
text-decoration: none;
text-transform: uppercase;
font-size: 1.1em;
outline: 0;
color: #FFF;
}
#nav li.active a {
color: #FFF;
}
#nav > ul > li > ul {
display: none;
}
#nav li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
Change your css like
#nav li:hover > ul
{
opacity: 1;
display: block;
margin: 0;
position:absolute;
background:green;
}
<nav id="nav">
<ul>
<li class="active">Homepage
<ul>
<li><a href="index.html">Homepage</li>
<li>Pictures</li>
<li>Contact</li>
</ul>
</li>
<li>Pictures</li>
<li>Contact</li>
</ul>
</nav>
CSS :
#nav
{
}
#nav-wrapper
{
background: rgba(0,0,0,.1);
text-align:center;
margin:0;
padding:0;
width: 100%;
}
#nav ul {
display: inline;
margin: 0;
padding: 0;
text-align: center;
padding: 15px 4px 17px 0;
list-style: none;
border-right: 1px solid;
border-color: rgba(255,255,255,.1);
color: white;
}
ul li {
border-right: 1px solid;
border-color: rgba(255,255,255,.1);
display: inline-block;
margin: -4px;
position: relative;
padding: 15px 20px;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
text-align: center;
color: white;
}
ul li:hover {
border-right: 1px solid;
border-color: rgba(255,255,255,.1);
color: white;
}
ul li ul {
position: absolute;
top: 90px;
left: 0;
width: 200px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
border-right: 1px solid;
border-color: rgba(255,255,255,.1);
background: rgba(0,0,0,.1);
display: block;
text-transform: uppercase;
font-size: 1.1em;
outline: 0;
color: #FFF;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
#nav ul li a,
#nav ul li span
{
display: inline-block;
padding: 1.5em 1.5em;
letter-spacing: 0.06em;
text-decoration: none;
text-transform: uppercase;
font-size: 1.1em;
outline: 0;
color: #FFF;
}
#nav li.active a
{
color: #FFF;
}
HTML :
<div id="header">
<div id="nav-wrapper">
<!-- Nav -->
<nav id="nav">
<ul>
<li class="active">Homepage</li>
<li>Pictures
<ul>
<li>test</li>
<li>test2</li>
</ul>
</li>
<li>Contact</li>
</ul>
</nav>
</div>
JSFIDDLE DEMO

Aligning a dropdown menu in CSS in all browsers

I have a dropdown menu that is generated from WordPress so I do not want to change the HTML of it. i can change the CSS as needed though and I pretty much have ot working as I need it with the exception of an alignment issue with my dropdown menu.
Google Chrome
FireFox
Internet Explorer
From the images above you can see that IE and FIreFox display it the same but Chrome is always different from the 2. My Goal is to get this box to align perfectly with the right of the menu button and then get it to look that way in all 3 of these browsers.
I have extracted the HTML and CSS into a JSFiddle page for testing and playing around with here...
Code View: http://jsfiddle.net/jasondavis/hAb4k/
Full View for viewing the menu: http://jsfiddle.net/jasondavis/hAb4k/embedded/result/
My HTML
<nav id="head-nav-menu" class="nav-main" role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
<ul id="nav" class="nav nav-pills">
<li class="active menu-home">
Home
</li>
<li class="menu-about">
About
</li>
<li class="menu-projects">
Projects
</li>
<li class="menu-blog">
Blog
</li>
<li class="dropdown menu-services">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="/services/">Services <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="menu-consulting">Consulting</li>
<li class="menu-magento-development">
Magento Development
</li>
<li class="menu-wordpress-development">
WordPress Development
</li>
<li class="menu-sugarcrm-development">
SugarCRM Development
</li>
<li class="menu-web-development">
Web Development
</li>
<li class="menu-seo">
SEO
</li>
</ul>
</li>
<li class="menu-contact">
Contact
</li>
</ul>
</nav>
CSS
body{
background: #40C8F4 !important;
}
nav ul, nav ol {
list-style: none;
list-style-image: none;
}
#head-nav-menu{
float: right;
margin-top: 29px;
}
#head-nav-menu li {
float: left;
position: relative;
padding: 0 2px 0 2px;
}
.nav a {
font-family: 'arial';
font-size: 18px;
padding: 8px 18px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
white-space: nowrap;
color: #fff;
opacity: 0.9;
letter-spacing: 1px;
text-decoration: none;
}
.menu-contact a {
border: 2px solid #FFF;
padding: 8px 18px;
transition: 0.05s linear;
-moz-transition: 0.05s linear;
-webkit-transition: 0.05s linear;
}
.nav .menu-contact a:hover {
background-color: #FFF;
color: #797979;
}
#nav ul a {
font-weight: 100;
}
.nav a:hover,
.nav > .active a {
opacity: 1;
background-color: #3DBCE6;
}
.nav > .active li a {
background-color: inherit;
}
.tinynav {
display: none;
width: 100%;
margin-top: .5em;
margin-bottom: .6em;
}
.nav li.button a {
background-color: rgba(255, 255, 255, 0.1);
border: 2px solid #FFF;
border-radius: 4px;
margin-top: 5px;
padding: 8px 18px;
font-family: 'ProximaNova-bold', Helvetica, Arial, sans-serif;
font-weight: normal;
margin-left: 16px;
color: #FFF !important;
}
.nav li.button a:hover {
background-color: #FFF;
opacity: 1;
color: #444 !important;
}
/* ==========================================================================
Main Container General Layout Styles
========================================================================== */
.header-container header {
padding-top: 13px;
padding-bottom: 18px;
}
/* Navigation > Dropdown Menus */
#nav .dropdown-menu,
#nav .children {
display: none;
padding: 0;
position: absolute;
z-index: 99999;
border: 1px solid #86DEFC;
width: 333%;
/*right: 8px;*/
left: -239%;
top: 23px;
background-color: #F2F9FC;
}
#nav .dropdown-menu li {
width: 195px;
float: left;
display: inline-block;
/*width: 50%;*/
}
.nav .dropdown-menu a {
color: #030303;
}
#nav li:hover > ul,
#nav ul li:hover > ul,
.dropdown:hover > ul {
display: inline-block;
-webkit-animation: fadeDown 250ms ease;
-moz-animation: fadeDown 250ms ease;
-ms-animation: fadeDown 250ms ease;
-o-animation: fadeDown 250ms ease;
animation: fadeDown 250ms ease;
background-color: #fff;
color: #000;
border: 1px solid #E9E9E9;
border-top: none;
}
#nav .dropdown-menu ul,
#nav .children ul {
left: 99.75%;
top: -1px;
}
#nav ul li,
#nav ul ul li {
margin-left: 0;
}
#nav ul li:first-child,
#nav ul ul li:first-child {
border-top: none;
}
#nav ul a,
#nav ul ul a {
font-size: 14px;
line-height: 21px;
text-align: left;
padding: 10px;
display: inline-block;
min-width: 125px;
border-bottom: none;
margin-bottom: 0 !important;
width: 100%;
letter-spacing: 1px;
font-family: arial;
}
#nav ul a:hover,
#nav ul ul a:hover {
color: #098EB9 !important;
background: none;
}
#nav ul ul.dropdown-menu a:hover {
width: 100%;
color: #63E924 !important;
border-bottom: none;
}
#nav li.current_page_item ul a,
#nav li.current-menu-parent ul a,
#nav li.current_page_parent ul a {
color: #000;
font-weight: 700;
}
#nav ul li.current-menu-item a {
color: #e9242e !important;
}
#head-nav-menu .nav li:hover a.dropdown-toggle {
background: #fff;
color: #000;
opacity: 1;
border-right: 1px solid #E7E7E7;
}
.nav .dropdown a:hover {
opacity: 1;
background-color: #fff;
}
#nav .dropdown-menu li:hover {
background: #F8F8F8;
}
Give display: block to .nav a
then remove left: 239% of #nav .dropdown-menu and give right: 2px and top: 38px to it.
Here is the edited demo for it.
http://jsfiddle.net/hAb4k/3/

When I hover over my nav menu it pushes content down, why? How do i change color of li when hover over?

When i hover over the navmenu it pushes other content down on the webpage. In addition, when you hover over the nav the font is no longer in white. I'm sorry I am new at programming and borrowed some of this code so it may be sloppy. Thanks
Here is my html:
<div class="nav">
<ul id="nav">
<li>Home</li>
<li>Shop Online</li>
<li>Online Rentals
<div>
<ul>
<li>Rent Now</li>
<b>Current Rental Customers</b>
<li>Rental Returns</li>
<li>Rental Repairs</li>
<li>Rental Exchanges</li>
</ul>
</div>
</li>
<li>Lessons
<div>
<ul>
<li>Private Lessons</li>
<li>Meet the Teachers</li>
<li>Request a Lesson</li>
</ul>
</div>
</li>
<li>Performing Arts Center
<div>
<ul>
<li>Musical Theater</li>
<li>Kindermusik</li>
<li>Recording Studio</li>
<li>Group Ensembles</li>
</ul>
</div>
</li>
<li>Repairs</li>
<li>My Account</li>
</ul>
</div>
Here is my css:
/* main menu styles */
#nav,#nav ul {
font-family: verdana;
list-style: none;
margin: 0;
padding: 0;
position: fixed;
}
#nav {
height: 50px;
left: 0;
overflow: hidden;
top: 0;
position: relative;
}
#nav li {
float:left;
position:relative;
z-index:10;
}
#nav li a {
background-repeat: no-repeat;
background-position: center top;
color: #fff;
display: inline;
float: left;
font-size: 14px;
height: 51px;
line-height: 40px;
padding: 0 10px;
position: relative;
text-decoration: none;
z-index: 20;
background-color: #005E20;
}
#nav li:first-child a {
background:url(file:///Macintosh%20HD/Users/davidscott/Downloads/example91/images/bg-menu.png) no-repeat left top;
padding-left:35px;
}
#nav li ul li:first-child a {
background-image:none;
padding-left:10px;
}
#nav li.pad {
background: url(file:///Macintosh%20HD/Users/davidscott/Downloads/example91/images/bg- menu.png) no-repeat right top;
display: inline;
height: 51px;
width: 35px;
}
#nav ul {
background-color: #FFFFFF;
height: auto;
padding: 10px 0;
position: absolute;
top: -115px;
width: 180px;
z-index: 1;
border-radius: 8px; /*some css3*/
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
transition: 0.8s ease-in-out;
box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
-moz-transition: 0.8s ease-in-out;
-o-transition: 0.8s ease-in-out;
-webkit-transition: all 0.8s ease-in-out;
color: #005E20;
}
#nav ul li {
width:180px;
}
#nav ul li a {
background:transparent;
height:20px;
line-height:20px;
width:160px;
}
#nav:hover {
height:200px;
}
#nav li:hover ul {
-moz-transform:translate(0,161px); /*some css3*/
-o-transform:translate(0,161px);
-webkit-transform:translate(0,161px);
}
#nav a:hover,#nav li:hover > a {
color:#99ff33;
}
This changes the height of the nav on hover (pushing the rest of the page down):
#nav:hover {
height:200px;
}
This changes the color to green on hover:
#nav a:hover, #nav li:hover > a {
color:#99ff33;
}
Here's a rudimentary example without those hover definitions:
http://jsfiddle.net/w4uyX/
It's all in your CSS code (which seems a bit unorganized to me).
To deal with the menu pushing other content down, please find the selector #nav:hover where a larger height is set.
Then find the selector #nav a:hover,#nav li:hover > a. There is the setting for the different color, when you hover over the menu.
see my navbar and see the difference
http://codepen.io/leandroruel/pen/yrwKI

Submenu doesn't overflow hidden

The problem is that when i hover on the area where the more link is, the menu appears and it should appear only if i have hovered over the More link, not on the area. I tried with overflow:hidden on the sub-menu .ktmsg ul li ul { but doesn't work.
I have the below code
HTML
<div class="ktmsg">
<li><a id="a0" href="#"> 0 </a></li>
<ul>
<li class="a1"> 1 </li>
<li>
More
<ul>
<li class="a4"> 4 </li>
<li class="a5"> 5 </li>
<li class="a6"> 6 </li>
</ul>
</li>
</ul>
</div>
CSS
.ktmsg {
font-size: 16px;
font-weight: normal;
margin: 0px;
height: 18px;
border-top-right-radius: 8px;
border-top-left-radius: 8px;
width: 930px;
padding: 0px;
text-align: left;
height: 20px;
position: relative;
font-weight: normal;
font-size: 15px;
background-color: red;
}
.ktmsg a{
text-align: center;
padding: 13px 4px;
white-space: nowrap;
float: left;
text-decoration: none;
background:red;
color: #FFF;
min-width: 150px;
transition: all 0.4s;
}
.ktmsg ul{
list-style: none outside none;
width: 100%;
position: relative;
padding-left:0px;
}
.ktmsg li {
float:left;
position:relative;
list-style-type: none;
display: inline;
padding: 0px;
margin: 0px 10px;
background-image: none;
}
.ktmsg li a, .ktmenu li a:active, .ktmenu li a:visited {
margin:0px;
color: #FFF;
border: 0px;
text-decoration: none;
font-weight: bold;
}
.ktmsg ul li a:hover {
color: blue;
text-decoration: none;
}
.ktmsg a, .ktmsg a:active, .ktmsg a:visited {
color: #FFF;
margin:0px;
padding: 0px;
text-decoration: none;
}
.ktmsg ul li ul {
overflow:hidden;
padding:0;
background:red;
opacity:0;
height:auto;
width:auto;
margin-top:25px;
position:absolute;
transition-property: opacity;
box-shadow: 0 0 2px 2px;
border-radius: 6px;
transition-duration: 1s;
transition-timing-function: linear;
transition-timing-function: ease-out;
}
.ktmsg ul li:hover ul{
overflow:visible;
display:block;
background:red;
height:auto;
width:auto;
margin-top:25px;
opacity: 1;
box-shadow: 0 0 2px 2px;
border-radius: 6px;
}
.ktmsg ul li ul li{
background:red;
padding: 10px;
border-bottom: 1px solid rgb(51, 51, 51);
}
Fiddle-DEMO
This is because min-width of .ktmsg a is set to 150px. I suggest you to move it to .ktmsg li and it should solve problem you are mentioned.
As well you have to change .ktmsg ul a:hover + ul this is selector what should be instead to .ktmsg ul li:hover ul. And as well .ktmsg a shouldn't have float: left and paddings.
To ul doesn't disappear you have to add one other selector:
.ktmsg ul a + ul:hover,
.ktmsg ul a:hover + ul {
overflow:visible;
display:block;
opacity: 1;
/* rest of style */
}
I think it is working as you want it to, it's just that you have a min-width of 150px applied to your a links which is making the more link wider than you think it is.
.ktmsg ul li ul {
overflow: hidden !important;
}
Remove min-width: 150px; from style