this is sort of a continuation of this solved question.
as you can see in this fiddle the 3rd level dropdown is working but the fix has created this unexplainable single pixel transparent border at the bottom of the dropdowns. You can see it if you look closely between the dropdown and the box-shadow.
html:
<nav id="menu" class="dark_menu">
<!-- Main Nav Start -->
<ul id="main-nav" class="clearfix">
<li id="port" class="parent menu-item">Portfolio
<ul class="clearfix">
<li id="regular" class="parent menu-item">Regular
<ul class="clearfix">
<li id="menu-item-1036" class="menu-item">4 columns
</li>
<li id="menu-item-1033" class="menu-item">3 columns
</li>
<li id="menu-item-1030" class="menu-item">3 columns w/ sidebar
</li>
<li id="menu-item-1029" class="menu-item">2 columns
</li>
</ul>
</li>
<li id="2col" class="parent menu-item">Ajax
</li>
</ul>
</li>
<li id="menu-item-1727" class="parent menu-item">About
<ul class="clearfix">
<li id="menu-item-870" class="menu-item">Who We Are
</li>
<li id="menu-item-872" class="menu-item">What We Do
</li>
</ul>
</li>
</ul>
</nav>
css:
a {
text-decoration:none;
}
ul {
padding-left:0px;
}
#menu {
position:relative;
border:none;
height:auto;
top:34px;
left:0px;
}
#menu ul {
margin:0;
list-style:none;
}
#menu li {
float:left;
position:relative;
}
#menu > ul > li > a {
padding:25px 26px 17px;
border-bottom:3px solid transparent;
margin-right:1px;
color:#6B6B6B;
font:11px Arial, sans-serif;
font-weight:bold;
text-align:center;
text-transform:uppercase;
display:block;
}
#menu > ul > li:hover > a {
color:#F15A2B;
border-color:#F15A2B;
}
#menu > ul li.selected > a, #menu > ul li.selected:hover > a {
color:#3B3B3B;
border-color:#3B3B3B;
}
/* Submenu (second level) */
#menu li > ul {
position:absolute;
top:auto;
left:0;
width:180px;
max-height:0;
box-shadow:1px 2px 10px rgba(100, 100, 100, 0.3);
visibility: hidden;
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: 216px;
transition-delay: 0s;
}
#menu ul li > ul:hover {
overflow:visible;
}
#menu li > ul li {
height:36px;
width:100%;
border-bottom:1px solid #EEE;
padding-top:0;
}
#menu li > ul li:last-child {
border-bottom:none;
}
#menu li > ul li a {
background:#FFF;
padding:11px 15px;
height:35px;
color:#999;
width:100%;
font:10px Arial, sans-serif;
font-weight:bold;
text-align:left;
text-transform:uppercase;
display:block;
}
#menu li > ul li:hover > a {
color:#FFF;
background:#F15A2B;
}
#menu li > ul li.selected > a, #menu li > ul li.selected:hover > a {
color:#3B3B3B;
background:#FFF;
}
/* Submenu (third level) */
#menu li > ul > li > ul {
position:absolute;
top:0 !important;
left:180px !important;
width:180px;
overflow:hidden;
box-shadow:1px 2px 10px rgba(100, 100, 100, 0.3);
visibility:hidden;
}
#menu li > ul > li:hover > ul {
visibility: visible;
}
#menu li > ul > li > ul > li:last-child {
border-bottom:none;
}
#menu li > ul li ul li a {
background:#FFF;
padding:11px 15px;
height:35px;
color:#999;
font:10px Arial, sans-serif;
font-weight:bold;
text-align:left;
text-transform:uppercase;
display:block;
}
#menu li > ul > li > ul > li:hover > a {
color:#FFF;
background:#F15A2B;
}
#menu li > ul li.selected > a, #menu li > ul li.selected:hover > a {
color:#3B3B3B;
background:#FFF;
}
/* Dark Menu */
#menu.dark_menu li ul li {
border-color:#464646;
}
#menu.dark_menu li ul li a {
background:#3B3B3B;
color:#999;
}
#menu.dark_menu li ul li:hover > a {
color:#FFF;
background:#F15A2B;
}
#menu.dark_menu li ul li.selected > a, #menu.dark_menu li ul li.selected:hover > a {
color:#FFF;
background:#3B3B3B;
}
* {
box-sizing:border-box;
-moz-box-sizing:border-box;
}
It looks like adding the following CSS below fixes your issue. If you want to remove the border on the last item, you have to make sure the element does not extend past its child height which is the only element with the background color.
#menu li > ul li:last-child {
border-bottom:none;
height: 35px;
}
Related
I have a responsive menu error that displays on mobile when it pushes the footer bar at the bottom of the page every time it appears and the sub-menu is opened.
You can see it working live on your phone at www.nhadatsonnghia.com nha dat go vap .
So how to fix this display error of responsive menu with css. Any suggestions are appreciated!
Thanks so much!
Here is my code :
#import url(http://fonts.googleapis.com/css?family=Arial:400,700);
#cssmenu,#cssmenu > ul,#cssmenu > ul > li,#cssmenu > ul > li a,#cssmenu #menu-button
{
display: block;
-moz-box-sizing: border-box;
list-style: none;
padding: 0;
}
#cssmenu:after,#cssmenu > ul:after
{
content:' .' ;
display:block;
clear:both;
visibility:hidden;
line-height:0;
height:0;
}
#cssmenu #menu-button { display:none; }
#cssmenu
{
position: relative;
text-align: center;
z-index: 15;
float: right;
}
#cssmenu > ul > li
{
position: relative;
vertical-align: middle;
display: inline-block;
padding: 0;margin: 0;
}
#cssmenu.align-center > ul
{
font-size:0;
text-align:center;
}
#cssmenu.align-center > ul > li
{
display:inline-block;
float:none;
}
#cssmenu.align-center ul ul
{
text-align:left;
}
#cssmenu.align-right > ul > li
{
float:right;
}
#cssmenu > ul > li > a
{
color: black;
font-size: 16px;
display: inline-block;
text-decoration: none;
letter-spacing: 1px;
margin: 10px 0 0 0;
padding: 0 12px;
font-family: Open Sans,Helvetica,Arial,sans-serif;
font-weight: 500;
line-height: 40px;
}
#cssmenu > ul > li:hover > a
{
color:#ffffff;
background: #ffbd2f;
border:1px;
border-radius:5px;
}
#cssmenu > ul > li.has-sub > a { padding-right:10px; }
#cssmenu > ul > li.has-sub > a:after
{
position:absolute;
top:0;
right:0;
width:0;
height:2px;
display:block;
background:#dddddd;
content:' ' ;
}
#cssmenu > ul > li.has-sub > a:before
{
position:absolute;
top:0; right:0;
display:block;
width:2px; height:0;
background:#dddddd;
content:' ' ;
-webkit-transition:all .25s ease; -moz-transition:all .25s ease; -ms-transition:all .25s ease; -o-transition:all .25s ease; transition:all .25s ease;
}
#cssmenu > ul > li.has-sub:hover > a:before { top:23px; height:0; }
#cssmenu ul ul { position:absolute; left:-9999px; z-index:9999; }
#cssmenu.align-right ul ul { text-align:right; }
#cssmenu ul ul li
{
height:0;
-webkit-transition:all .25s ease; -moz-transition:all .25s ease; -ms-transition:all .25s ease; -o-transition:all .25s ease; transition:all .25s ease;
position: relative;
list-style: none;
}
#cssmenu ul ul ul li {
height:0;
-webkit-transition:all .25s ease;
-moz-transition:all .25s ease;
-ms-transition:all .25s ease;
-o-transition:all .25s ease;
transition:all .25s ease;
}
#cssmenu li:hover > ul { left:auto; }
#cssmenu.align-right li:hover > ul { left:auto; right:0; }
#cssmenu li:hover > ul > li { height:35px; }
#cssmenu ul ul ul { margin-left:100%; top:0; }
#cssmenu.align-right ul ul ul { margin-left:0; margin-right:100%; }
#cssmenu ul ul li a
{
border-bottom:1px solid rgba(150,150,150,0.15);
padding:15px;
width:250px;
font-size:13px;
text-decoration:none;
color:#dddddd;
font-weight:400;
background:#333333;
}
#cssmenu ul ul li:last-child > a,#cssmenu ul ul li.last-item > a { border-bottom:0; }
#cssmenu ul ul li:hover > a,#cssmenu ul ul li a:hover { color:#ffffff; }
#cssmenu ul ul li.has-sub > a:after
{
position:absolute;
top:16px; right:11px;
width:8px; height:2px;
display:block; background:#dddddd;
content:' ' ;
}
#cssmenu.align-right ul ul li.has-sub > a:after { right:auto; left:11px; }
#cssmenu ul ul li.has-sub > a:before
{
position:absolute;
top:13px; right:14px;
display:block;
width:2px; height:8px;
background:#dddddd; content:' ' ;
-webkit-transition:all .25s ease; -moz-transition:all .25s ease; -ms-transition:all .25s ease; -o-transition:all .25s ease; transition:all .25s ease;
}
#cssmenu.align-right ul ul li.has-sub > a:before { right:auto; left:14px; }
#cssmenu ul ul > li.has-sub:hover > a:before { top:17px; height:0; }
#media all and (max-width:768px),only screen and (-webkit-min-device-pixel-ratio:2) and (max-width:1024px),only screen and (min--moz-device-pixel-ratio:2) and (max-width:1024px),only screen and (-o-min-device-pixel-ratio:2/1) and (max-width:1024px),only screen and (min-device-pixel-ratio:2) and (max-width:1024px),only screen and (min-resolution:192dpi) and (max-width:1024px),only screen and (min-resolution:2dppx) and (max-width:1024px) {
#menu-desktop
{
float:left;
background: #ffbd2f;
padding: 0 5px;
display: block;
}
#cssmenu { width:100%; }
#cssmenu ul { width:100%; display:none; }
#cssmenu.align-center > ul { text-align:left; }
#cssmenu ul li { width:100%; border-top:1px solid rgba(120,120,120,0.2); }
#cssmenu ul ul li,#cssmenu li:hover > ul > li { height:auto; }
#cssmenu ul li a,#cssmenu ul ul li a { width:100%; border-bottom:0; }
#cssmenu > ul > li { float:none; }
#cssmenu ul ul li a { padding-left:25px; }
#cssmenu ul ul ul li a { padding-left:35px; }
#cssmenu ul ul li a { color:#dddddd; background:none; }
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a { color:#ffffff; }
#cssmenu ul ul,#cssmenu ul ul ul,#cssmenu.align-right ul ul
{
position:relative;
left:0;
width:100%;
margin:0;
text-align:left;
}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before { display:none; }
#cssmenu #menu-button
{
display:block;
padding:32px;
color:#dddddd;
cursor:pointer;
font-size:12px;
text-transform:uppercase;
font-weight:700;
}
#cssmenu #menu-button:after
{
position:absolute;
top:26px; right:13px;
display:block;
height:5px; width:40px;
border-top:5px solid #ffffff;
border-bottom:5px solid #ffffff;
content:' ' ; }
#cssmenu #menu-button:before
{
position:absolute;
top:16px; right:13px;
display:block;
height:5px; width:40px;
background:#ffffff;
content:' ' ; }
#cssmenu #menu-button.menu-opened:after
{
top:23px;
border:0;
height:10px; width:40px;
background:#ffffff; -webkit-transform:rotate(45deg); -moz-transform:rotate(45deg); -ms-transform:rotate(45deg); -o-transform:rotate(45deg); transform:rotate(45deg);
}
#cssmenu #menu-button.menu-opened:before
{
top:23px;
background:#ffffff;
width:40px;
height:10px;
-webkit-transform:rotate(-45deg); -moz-transform:rotate(-45deg); -ms-transform:rotate(-45deg); -o-transform:rotate(-45deg); transform:rotate(-45deg);
}
#cssmenu .submenu-button
{
position:absolute;
z-index:99;
right:0;
top:0;
display:block;
border-left:1px solid rgba(120,120,120,0.2);
height:46px; width:46px;
cursor:pointer; }
#cssmenu .submenu-button.submenu-opened { background:#262626; }
#cssmenu ul ul .submenu-button { height:34px; width:34px; }
#cssmenu .submenu-button:after
{
position:absolute;
top:22px; right:19px;
width:8px; height:2px;
display:block;
background:#dddddd;
content:' ' ;
}
#cssmenu ul ul .submenu-button:after { top:15px; right:13px; }
#cssmenu .submenu-button.submenu-opened:after { background:#ffffff; }
#cssmenu .submenu-button:before
{
position:absolute;
top:19px; right:22px;
display:block;
width:2px; height:8px;
background:#dddddd;
content:' ' ;
}
#cssmenu ul ul .submenu-button:before { top:12px; right:16px; }
#cssmenu .submenu-button.submenu-opened:before { display:none; }
}
<div id="menu-desktop">
<div id="cssmenu">
<div id="menu-button" class="menu-opened"></div>
<ul class="open" style="display: block;">
<li>Nhà Đất Sơn Nghĩa</li>
<li class="active has-sub">
<span class="submenu-button submenu-opened"></span>
Nhà Đất Gò Vấp
<ul class="open" style="display: block;">
<li>Bán Nhà Gò Vấp mặt phố, mặt tiền</li>
<li>Nhà Gò Vấp giá dưới 1 tỷ</li>
<li>Nhà Gò Vấp giá 1 đến 2 tỷ</li>
<li>Nhà Gò Vấp giá 2 đến 3 tỷ</li>
<li>Nhà Gò Vấp giá 3 đến 4 tỷ</li>
<li class="active has-sub">
<span class="submenu-button submenu-opened"></span>
Nhà Đất Gò Vấp bán theo phường
<ul class="open" style="display: block;">
<li>Phường 8</li>
<li>Phường 9</li>
<li>Phường 13</li>
<li>Phường 16</li>
<li>Phường 17</li>
</ul>
</li>
</ul>
</li>
<li>Nhà Đất Quận 12</li>
</ul>
</div></div>
Suggesting you to use Absolute position for the sub menu so it can overlap the footer instead of pushing it when expanded.
Hope it helps.
Fixed Version:
#import url(http://fonts.googleapis.com/css?family=Arial:400,700);
#cssmenu,#cssmenu > ul,#cssmenu > ul > li,#cssmenu > ul > li a,#cssmenu #menu-button
{
display: block;
-moz-box-sizing: border-box;
list-style: none;
padding: 0;
}
#cssmenu:after,#cssmenu > ul:after
{
content:' .' ;
display:block;
clear:both;
visibility:hidden;
line-height:0;
height:0;
}
#cssmenu #menu-button { display:none; }
#cssmenu
{
position: relative;
text-align: center;
z-index: 15;
float: right;
}
#cssmenu > ul > li
{
position: relative;
vertical-align: middle;
display: inline-block;
padding: 0;margin: 0;
}
#cssmenu.align-center > ul
{
font-size:0;
text-align:center;
}
#cssmenu.align-center > ul > li
{
display:inline-block;
float:none;
}
#cssmenu.align-center ul ul
{
text-align:left;
}
#cssmenu.align-right > ul > li
{
float:right;
}
#cssmenu > ul > li > a
{
color: black;
font-size: 16px;
display: inline-block;
text-decoration: none;
letter-spacing: 1px;
margin: 10px 0 0 0;
padding: 0 12px;
font-family: Open Sans,Helvetica,Arial,sans-serif;
font-weight: 500;
line-height: 40px;
}
#cssmenu > ul > li:hover > a
{
color:#ffffff;
background: #ffbd2f;
border:1px;
border-radius:5px;
}
#cssmenu > ul > li.has-sub > a { padding-right:10px; }
#cssmenu > ul > li.has-sub > a:after
{
position:absolute;
top:0;
right:0;
width:0;
height:2px;
display:block;
background:#dddddd;
content:' ' ;
}
#cssmenu > ul > li.has-sub > a:before
{
position:absolute;
top:0; right:0;
display:block;
width:2px; height:0;
background:#dddddd;
content:' ' ;
-webkit-transition:all .25s ease; -moz-transition:all .25s ease; -ms-transition:all .25s ease; -o-transition:all .25s ease; transition:all .25s ease;
}
#cssmenu > ul > li.has-sub:hover > a:before { top:23px; height:0; }
#cssmenu ul ul { position:absolute; left:-9999px; z-index:9999; }
#cssmenu.align-right ul ul { text-align:right; }
#cssmenu ul ul li
{
height:0;
-webkit-transition:all .25s ease; -moz-transition:all .25s ease; -ms-transition:all .25s ease; -o-transition:all .25s ease; transition:all .25s ease;
position: relative;
list-style: none;
}
#cssmenu ul ul ul li {
height:0;
-webkit-transition:all .25s ease;
-moz-transition:all .25s ease;
-ms-transition:all .25s ease;
-o-transition:all .25s ease;
transition:all .25s ease;
}
#cssmenu li:hover > ul { left:auto; height: auto; }
#cssmenu.align-right li:hover > ul { left:auto; right:0; }
#cssmenu li:hover > ul > li { height:35px; }
#cssmenu ul ul ul { margin-left:100%; top:0; }
#cssmenu.align-right ul ul ul { margin-left:0; margin-right:100%; }
#cssmenu ul ul li a
{
border-bottom:1px solid rgba(150,150,150,0.15);
padding:15px;
width:250px;
font-size:13px;
text-decoration:none;
color:#dddddd;
font-weight:400;
background:#333333;
}
#cssmenu ul ul li:last-child > a,#cssmenu ul ul li.last-item > a { border-bottom:0; }
#cssmenu ul ul li:hover > a,#cssmenu ul ul li a:hover { color:#ffffff; }
#cssmenu ul ul li.has-sub > a:after
{
position:absolute;
top:16px; right:11px;
width:8px; height:2px;
display:block; background:#dddddd;
content:' ' ;
}
#cssmenu.align-right ul ul li.has-sub > a:after { right:auto; left:11px; }
#cssmenu ul ul li.has-sub > a:before
{
position:absolute;
top:13px; right:14px;
display:block;
width:2px; height:8px;
background:#dddddd; content:' ' ;
-webkit-transition:all .25s ease; -moz-transition:all .25s ease; -ms-transition:all .25s ease; -o-transition:all .25s ease; transition:all .25s ease;
}
#cssmenu.align-right ul ul li.has-sub > a:before { right:auto; left:14px; }
#cssmenu ul ul > li.has-sub:hover > a:before { top:17px; height:0; }
#media all and (max-width:768px),only screen and (-webkit-min-device-pixel-ratio:2) and (max-width:1024px),only screen and (min--moz-device-pixel-ratio:2) and (max-width:1024px),only screen and (-o-min-device-pixel-ratio:2/1) and (max-width:1024px),only screen and (min-device-pixel-ratio:2) and (max-width:1024px),only screen and (min-resolution:192dpi) and (max-width:1024px),only screen and (min-resolution:2dppx) and (max-width:1024px) {
#menu-desktop
{
float:left;
background: #ffbd2f;
padding: 0 5px;
display: block;
}
#cssmenu { width:100%; }
#cssmenu ul { width:100%; display:none; }
#cssmenu.align-center > ul { text-align:left; }
#cssmenu ul li { width:100%; border-top:1px solid rgba(120,120,120,0.2); }
#cssmenu ul ul li,#cssmenu li:hover > ul > li { height:auto; }
#cssmenu ul li a,#cssmenu ul ul li a { width:100%; border-bottom:0; }
#cssmenu > ul > li { float:none; }
#cssmenu ul ul li a { padding-left:25px; }
#cssmenu ul ul ul li a { padding-left:35px; }
#cssmenu ul ul li a { color:#dddddd; background:none; }
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a { color:#ffffff; }
#cssmenu ul ul,#cssmenu ul ul ul,#cssmenu.align-right ul ul
{
position:relative;
left:0;
width:100%;
margin:0;
text-align:left;
box-sizing: border-box;
}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before { display:none; }
#cssmenu #menu-button
{
display:block;
padding:32px;
color:#dddddd;
cursor:pointer;
font-size:12px;
text-transform:uppercase;
font-weight:700;
}
#cssmenu #menu-button:after
{
position:absolute;
top:26px; right:13px;
display:block;
height:5px; width:40px;
border-top:5px solid #ffffff;
border-bottom:5px solid #ffffff;
content:' ' ; }
#cssmenu #menu-button:before
{
position:absolute;
top:16px; right:13px;
display:block;
height:5px; width:40px;
background:#ffffff;
content:' ' ; }
#cssmenu #menu-button.menu-opened:after
{
top:23px;
border:0;
height:10px; width:40px;
background:#ffffff; -webkit-transform:rotate(45deg); -moz-transform:rotate(45deg); -ms-transform:rotate(45deg); -o-transform:rotate(45deg); transform:rotate(45deg);
}
#cssmenu #menu-button.menu-opened:before
{
top:23px;
background:#ffffff;
width:40px;
height:10px;
-webkit-transform:rotate(-45deg); -moz-transform:rotate(-45deg); -ms-transform:rotate(-45deg); -o-transform:rotate(-45deg); transform:rotate(-45deg);
}
#cssmenu .submenu-button
{
position:absolute;
z-index:99;
right:0;
top:0;
display:block;
border-left:1px solid rgba(120,120,120,0.2);
height:46px; width:46px;
cursor:pointer; }
#cssmenu .submenu-button.submenu-opened { background:#262626; }
#cssmenu ul ul .submenu-button { height:34px; width:34px; }
#cssmenu .submenu-button:after
{
position:absolute;
top:22px; right:19px;
width:8px; height:2px;
display:block;
background:#dddddd;
content:' ' ;
}
#cssmenu ul ul .submenu-button:after { top:15px; right:13px; }
#cssmenu .submenu-button.submenu-opened:after { background:#ffffff; }
#cssmenu .submenu-button:before
{
position:absolute;
top:19px; right:22px;
display:block;
width:2px; height:8px;
background:#dddddd;
content:' ' ;
}
#cssmenu ul ul .submenu-button:before { top:12px; right:16px; }
#cssmenu .submenu-button.submenu-opened:before { display:none; }
}
.absolute-sub {
height: 0;
position: absolute !important;
background-color: #ffbd2f;
overflow: hidden;
top: 46px;
}
<head>
<link rel="stylesheet" href="style.css">
</head>
<div id="menu-desktop">
<div id="cssmenu">
<div id="menu-button" class="menu-opened"></div>
<ul class="open" style="display: block;">
<li>Nhà Đất Sơn Nghĩa</li>
<li class="active has-sub">
<span class="submenu-button submenu-opened"></span>
Nhà Đất Gò Vấp
<ul class="open" style="display: block;">
<li>Bán Nhà Gò Vấp mặt phố, mặt tiền</li>
<li>Nhà Gò Vấp giá dưới 1 tỷ</li>
<li>Nhà Gò Vấp giá 1 đến 2 tỷ</li>
<li>Nhà Gò Vấp giá 2 đến 3 tỷ</li>
<li>Nhà Gò Vấp giá 3 đến 4 tỷ</li>
<li class="active has-sub">
<span class="submenu-button submenu-opened"></span>
Nhà Đất Gò Vấp bán theo phường
<ul class="open absolute-sub" style="display: block;">
<li>Phường 8</li>
<li>Phường 9</li>
<li>Phường 13</li>
<li>Phường 16</li>
<li>Phường 17</li>
</ul>
</li>
</ul>
</li>
<li>Nhà Đất Quận 12</li>
</ul>
</div></div>
I'm coding a website for uni right now and it's going pretty well, with the exception of a dropdown menu issue. I've given the li property an ID of "selected" on some menu options (when the user is on the page in question), so that it changes colour to a dark pink.
However, the dropdown options underneath whatever has the li id of "selected" all turn dark pink too. When I add a closed li tag at the end of "about" in the html, the dropdown doesn't appear at all.
I'll post the relevant html and CSS as well as screenshots, hopefully someone could help me, please!
THIS is how a dropdown menu (without the id of "selected") looks normally. the links work and it goes slightly darker when i hover over, which is what i want
whereas THIS has the "selected" id. i don't want the dropdown menu this colour - JUST the "about" box
Here's all of the dropdown code:
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#ffeff8;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:"Luna";
text-transform: lowercase;
border:1px solid #ed85c4;
}
.menu a {
transition:all linear 0.15s;
color:#ed85c4;
background:#ffeff8;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#d771ae;
}
.menu .arrow {
font-size:10px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:14px;
}
.menu > ul > li > a {
padding:3px 40px;
display:inline-block;
text-shadow:0px 0px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > a {
background:#f1dae8;
}
.menu > ul > li#selected a{
color: #ffeff8;
background: #c864a1;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:100%;
padding:0px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 0px 0px rgba(0,0,0,0.2);
}
.sub-menu li {
display:block;
font-size:12px;
text-transform: lowercase;
font-kerning: auto;
}
.sub-menu li a {
padding:10px 30px;
display:block;
background: #ffeff8;
}
.sub-menu li a:hover, .sub-menu a {
background: #f1dae8;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li id="selected">
about <span class="arrow">▼</span>
<ul class="sub-menu">
<li>history</li>
<li>values</li>
<li>the truck</li>
<li>produce info.</li>
</ul>
</li>
You did not select correctly the link below the #selected list item.
.menu > ul > li#selected a /*This selects all links below the selected li, including links in child list items*/
should be
.menu > ul > li#selected > a /* this selects the immediate descendent link only */
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#ffeff8;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:"Luna";
text-transform: lowercase;
border:1px solid #ed85c4;
}
.menu a {
transition:all linear 0.15s;
color:#ed85c4;
background:#ffeff8;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#d771ae;
}
.menu .arrow {
font-size:10px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:14px;
}
.menu > ul > li > a {
padding:3px 40px;
display:inline-block;
text-shadow:0px 0px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > a {
background:#f1dae8;
}
.menu > ul > li#selected >a{
color: #ffeff8;
background: #c864a1;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:100%;
padding:0px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 0px 0px rgba(0,0,0,0.2);
}
.sub-menu li {
display:block;
font-size:12px;
text-transform: lowercase;
font-kerning: auto;
}
.sub-menu li a {
padding:10px 30px;
display:block;
background: #ffeff8;
}
.sub-menu li a:hover, .sub-menu a {
background: #f1dae8;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li id="selected">
about <span class="arrow">▼</span>
<ul class="sub-menu">
<li>history</li>
<li>values</li>
<li>the truck</li>
<li>produce info.</li>
</ul>
</li>
*
I don't know what I am doing wrong here so can you help me? I want to create a cascading drop-down menu and I can't see what I am doing wrong. I've tried everything. I am just out of ideas
*
HERE IS MY CODE
<style type="text/css">
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background:#2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1{
z-index:1;
opacity:1;
}
.sub-menu {
width:160%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2728;
}
.sub-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a{
padding:10px 30px;
display:block;
}
.sub-menu1 li a{
padding:10px 10px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
}
</style>
</body>
</html>
<html>
<head>
<title> Australia </title>
</head>
<body>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Sydney
<ul class="sub-menu1">
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
You can use adjacent sibling selector for more info visit this link On a CSS hover event, can I change another div's styling?
Set display:none initially to sub-menu1 class and on hover of sub-menu li a set display of adjacent sub-menu1 back to block.
Here is the code:
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background:#2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1{
z-index:1;
opacity:1;
}
.sub-menu {
width:160%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2728;
}
.sub-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
display: none;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
display: block;
}
.sub-menu li a:hover + .sub-menu1{
display:block;
padding:10px 10px;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Sydney
<ul class="sub-menu1">
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
Or you can have an indentation on your submenus? It really depends on what you want. Could you give some example? Here's what I meant when I was talking about indentation :
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:19px;
}
.menu > ul > li > a {
padding:10px 40px;
display:inline-block;
text-shadow:0px 1px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background:#2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1{
z-index:1;
opacity:1;
}
.sub-menu {
width:160%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2728;
}
.sub-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a{
padding:10px 30px;
display:block;
}
.sub-menu1 li a{
padding:10px 10px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>
Sydney
<ul>
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
First of all,you must write 0 instead of 0px.
you must make the sub-menu1 display: none; then when mouse is on sydney the sub-menu must be display: block;
i have fixed somethings and this will be your code:
body {
background: #bf5c71;
}
.clearfix:after {
display: block;
clear: both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width: 100%;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
background: #3e3436;
}
.menu {
width: 1000px;
margin: 0 auto;
}
.menu li {
margin: 0;
list-style: none;
font-family: 'Ek Mukta';
}
.menu a {
transition: all linear 0.15s;
color: #919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration: none;
color: #be5b70;
}
.menu .arrow {
font-size: 11px;
line-height: 0;
}
/*----- Top Level -----*/
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu > ul > li > a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background: #2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu,
.menu li:hover .sub-menu1 {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0;
position: absolute;
top: 0;
left: 0;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
#sydney:hover .sub-menu1 {
display: block;
}
.sub-menu1 {
width: 100%;
padding: 0;
position: relative;
top: 0;
left: 370px;
z-index: 100;
opacity: 50;
transition: opacity linear .15s;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2758;
display: none;
}
.sub-menu li,
.sub-menu1 li {
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a {
background: #3e3436;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li id="sydney">Sydney
<ul class="sub-menu1">
<li>Test</li>
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
For whatever reason, when I add a radio check into the css, it will appear in the menu but will not show any of the menu items. Any tips on getting it to toggle properly would be a huge help!
Here's the fiddle:
http://jsfiddle.net/casslt07/kjjvp1bx/
**HTML**
<div id="nav">
<nav id="nav" class="clearfix">
<!-- nav menu top level -->
<input type="checkbox" id="menu-toggle">
<label for="button" onclick></label>
<ul class="first-level">
<li>Home
<li><a>Posts</a>
<ul>
<li>Listings</li>
<li>Comics</li>
<li>Observations</li>
<li>Poems</li>
<li>Short Stories</li>
</ul>
</li>
<li>Photos
</li>
<li>Videos</li>
<li>About the Author</li>
</ul>
<?php get_search_form(); ?> </nav>
</div>
**CSS:**
/* Config */
body {font-family:Arial}
ul, li {list-style:none; margin:0; padding:0;}
#menu-toggle {
display:none;
}
#nav label {
display:none;
font-size:20px;
list-style:none;
}
/* Nav */
#nav {
background-color:#33447A;
height: inherit;
border-bottom: 3px solid #13EBC7;
position:relative;
display:block; width: 100%; overflow:visible;}
#nav a {
color:#fff; display:block; font-size: 11pt; padding:18px 20px; text-decoration:none; text-align: left;}
#nav ul li {position:relative;}
/* First-Level */
#nav li {transition:background-color .5s; float:left;}
#nav li:hover {background-color:#50AEED; -webkit-transition: margin-bottom .2s; /* Safari 3.1 to 6.0 */
transition: margin-bottom .2s;}
#nav > ul > li {display:block; float:left; }
/* Second-level */
#nav li ul {width: 100%;}
#nav > ul li:hover > ul {opacity:1; top:54px; visibility:visible; border-radius: 4px; z-index:3; }
#nav .first-level .second-level > li {float:left;}
#nav > ul ul {opacity:0; visibility:hidden; position:absolute; top:60px; transition:all .25s; width:1000px;}
#nav > ul ul li {background-color:#3498db; left:0;}
#nav > ul ul li a {padding:10px 20px}
/* Clearfix */
.clearfix:after {visibility: hidden; display: block; font-size: 0; content:" "; clear:both; height:0;}
.nav-search {
opacity: .25;
width:35%;
float: right;
display:inline;
position: relative;
background: #3498db;
background: url('http://1touchsigns.com/images/search.gif');
background-repeat: no-repeat;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
border:none;
top:7px;
padding:6px;
outline:none;
transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-webkit-transition: all .3s ease-in-out;
}
.nav-search:focus {
background: white;
opacity: 1;
}
#responsive {
display: none;
}
#media only screen and (max-width: 480px) {
#menu-toggle {
display:block;
}
#nav label {display: block;height:50px;width:50px;line-height:50px;text-align:center;color:white;font-size:150%;background-color: #83CE69; cursor:pointer;}
#menu-toggle:checked + #nav {display: block;}
#nav label:active #nav {display: none;}
#nav {
display: block;
width: 100%;
height:auto;
float: right;
margin-right: 10px;
background-color: #232323;
border-bottom-width: 0px;
}
#nav ul {
display:none;
}
#nav ul:hover {
display:block;
}
#nav li {
width:100%;
}
#nav ul ul li {
width:100%;
color:white;
background-color:black;
display:block;
}
#nav ul ul li:hover {
display:block;
}
}
Add
#menu-toggle:checked + label + ul {
display: block;
}
http://jsfiddle.net/kjjvp1bx/3/
Or use jQuery, both works:
http://jsfiddle.net/kjjvp1bx/2/
Whenever I hover my mouse under the buttons that have drop down menus, the drop down menu shows. I want to make it so the drop down menu only shows when I put my mouse over the actual button.
FIDDLE CODE
HTML
<div id="navbar">
<ul>
<li>Home</li>
<li>Cakes
<ul>
<li >Budget Cakes</li>
<li>Wedding</li>
<li >Cakes to Go</li>
<li >Cake Bonbons</li>
<li >Holiday Cakes</li>
<li >Cakes for Girls</li>
<li >Cakes for Boys</li>
<li >For Her</li>
<li >For Him</li>
<li >Cupcakes</li>
</ul>
</li>
<li>Classes</li>
<li>Flavors</li>
<li>Events
<ul>
<li>Beach Wedding</li>
<li>Baby Showers</li>
<li>Sweet 15-16</li>
</ul>
</li>
<li>Contact</li>
<li>Questions</li>
</ul>
</div><!--end of navbar-->
CSS
#navbar ul li:hover > ul {
height:auto !important;
opacity:1;
}
#navbar ul li:hover > ul > li {
height:50px !important;
opacity:1;
}
#navbar ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 40px;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
list-style:none;
position:relative;
display:inline-table;
}
#navbar ul:after {
content:"";
clear: both;
display: block;
}
#navbar ul li {
float:left;
-webkit-transition:background 0.3s ease-in;
-moz-transition:background 0.3s ease-in;
-o-transition:background 0.3s ease-in;
-ms-transition:background 0.3s ease-in;
transition:background 0.3s ease-in;
position:relative;
}
#navbar ul li:hover {
background:#4b545f;
}
#navbar ul li:hover a {
color:#fff;
}
#navbar ul li a {
display:block;
padding:25px 40px;
color:#757575;
text-decoration:none;
}
#navbar ul ul {
background: #5f6975;
border-radius:0px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
padding: 0;
position:absolute;
top:100%;
left:0px;
width:195px;
z-index:1;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
height:0px;
}
#navbar ul ul li {
float:none;
border-top:1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position:relative;
height:0px;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
}
#navbar ul ul li a {
padding: 15px 40px;
color:#fff;
}
#navbar ul ul li a:hover {
background: #4b545f;
}
#navbar {
text-align:center;
}
#navbar ul ul ul {
position:absolute;
left:100%;
top:0;
width:155px;
}
It's because your nested <ul> still has a height, and so when you hover on it, the browser considers that as hovering on part of the first <li>.
Easiest way to fix it is to set the subnav ul to display: block and overflow: hidden.
#navbar ul ul {
...(existing styles)
display: block;
overflow: hidden;
}
Demo
Alternatively, you can toggle visibility: hidden.
#navbar ul ul {
...(existing styles)
visibility: hidden; /* ADD */
}
#navbar ul li:hover > ul {
...(existing styles)
visibility: visible; /* ADD */
}
Demo 2
Add following CSS.
#navbar ul ul {
display: block;
overflow: hidden;
}