Sub-Sub menus of CSS nav Bar is not expanding to right - html

I have written a code for a Nav bar. I have menu, sub menu and sub-sub menus. Menu and Sub-menus are working fine. The sub-sub menus are not working. They are expanding vertically instead of horizontally.
The html code is:
<div id="topbar">
<div class="wrapper">
<div id="topnav">
<ul>
<li class="active">Home</li>
<li>Products
<ul>
<li>Laptop & Notebooks
<ul>
<li>Acer</li>
<li>Apple</li>
</ul>
</li>
<li>Smartphone & Tablets</li>
<li>Desktop</li>
<li>Accessories
<ul>
<li>RAM</li>
<li>Casing</li>
<li>Ups & IPS</li>
</ul>
</li>
<li>Brand PC</li>
<li>Clone PC</li>
<li>Camera</li>
</ul>
</li>
<li>IT Solutions
<ul>
<li>Web Developmnet & Hosting</li>
<li>Mobile Application Development
<ul>
<li>Android Platform</li>
<li>Windows Platform</li>
</ul>
</li>
<li>Software Developement</li>
</ul>
<li>Portfolio</li>
<li>Contact Us</li>
</li>
</ul>
</div>
</div>
and the CSS is here :
#topnav{
display:block;
float:left;
width:660px;
margin:0;
padding:0;
list-style:none;
font-size:13px;
font-weight:normal;
font-family:Verdana, Arial, Helvetica, sans-serif;
color:#FFFFFF;
background-color:#000000;
}
#topnav ul, #topnav li{
float:left;
list-style:none;
margin:0;
padding:0;
}
#topnav li a:link, #topnav li a:visited, #topnav li a:hover{
display:block;
margin:0;
padding:15px 20px;
color:#FFFFFF;
background-color:#000000;
}
#topnav ul ul li a:link, #topnav ul ul li a:visited{
border:none;
}
#topnav li.last a{
margin-right:0;
}
#topnav li a:hover, #topnav ul li.active a{
color:#FFFFFF;
background-color:#059BD8;
}
#topnav li li a:link, #topnav li li a:visited{
width:150px;
float:none;
margin:0;
padding:7px 10px;
font-size:12px;
font-weight:normal;
color:#FFFFFF;
background-color:#000000;
}
#topnav li li a:hover{
color:#FFFFFF;
background-color:#059BD8;
}
#topnav li ul{
background:#FFFFFF;
z-index:9999;
position:absolute;
left:-999em;
height:auto;
width:170px;
border-left:1px solid #FFFFFF;
border-bottom:1px solid #FFFFFF;
}
#topnav li ul a{width:140px;}
#topnav li ul ul{margin:-32px 0 0 0;}
#topnav li:hover ul ul{left:-999em;}
#topnav li:hover ul, #topnav li li:hover ul{left:auto;}
#topnav li:hover{position:static;}
#topnav li.last a{margin-right:0;}
/* ----------------------------------------------Column Navigation-------------------------------------*/
#column .subnav{display:block; width:250px; padding:25px; background-color:#F9F9F9; margin-bottom:30px;}
#column .subnav h2{
margin:0 0 20px 0;
padding:0 0 14px 0;
font-size:20px;
font-weight:normal;
font-family:Georgia, "Times New Roman", Times, serif;
color:#666666;
background-color:#F9F9F9;
line-height:normal;
border-bottom:1px dotted #666666;
}
#column .subnav ul{
margin:0;
padding:0;
list-style:none;
}
#column .subnav li{
margin:0 0 3px 0;
padding:0;
}
#column .subnav ul ul, #column .subnav ul ul ul, #column .subnav ul ul ul ul, #column .subnav ul ul ul ul ul{border-top:none; padding-top:0;}
#column .subnav a{
display:block;
margin:0;
padding:5px 10px 5px 20px;
color:#777777;
background:url("../images/blue_file.gif") no-repeat 10px center #F9F9F9;
text-decoration:none;
border-bottom:1px dotted #666666;
}
#column .subnav a:hover{color:#059BD8; background-color:#F9F9F9;}
#column .subnav ul ul a, #column .subnav ul ul ul a, #column .subnav ul ul ul ul a, #column .subnav ul ul ul ul ul a{background:url("../images/black_file.gif") no-repeat #F9F9F9;}
#column .subnav ul ul a{padding-left:40px; background-position:30px center;}
#column .subnav ul ul ul a{padding-left:50px; background-position:40px center;}
#column .subnav ul ul ul ul a{padding-left:60px; background-position:50px center;}
#column .subnav ul ul ul ul ul a{padding-left:70px; background-position:60px center;}
Jsfiddle link: http://jsfiddle.net/98TRb/

Try adding this to your CSS:
#topnav ul ul li:hover ul {left:170px}
See it in action: http://jsfiddle.net/98TRb/1/

#topnav li ul ul li {display:inline-block; margin-left:40px; background-position:40px; text-align:center; border: 1px red solid; background-color: silver;}
Feel free to experiment with this. I changed colors so it would stand out for you.

Related

Creating a dropdown menu in an existing navigation bar

I'm currently working on my website and I have an existing navigation bar. The problem is that I have too much information to share on one page. That's why I'd like to implement a dropdown menu in the existing navigation bar. I've tried many many things but it all seems to screw up my lay-out of the css or it completely deletes the navigation bar.
I got an exisiting code for a dropdown menu but I simply am not able to blend it with the existing css code. I got this code from the internet, it is not my property.
My HTML:
<div id="menu">
<ul>
<li class="current_page_item">Home</li>
<li>Onze service</li>
<li>Ons team</li>
<li>Prijzen</li>
<li>Contact</li>
</ul>
</div>
My CSS:
#menu
{
position: absolute;
right: 0;
top: 1em;
}
#menu ul
{
display: inline-block;
}
#menu li
{
display: block;
float: left;
text-align: center;
line-height: 60px;
}
#menu li a, #menu li span
{
display: inline-block;
margin-left: 1px;
padding: 0em 1.5em;
letter-spacing: 0.10em;
text-decoration: none;
font-size: 1.0em;
text-transform: uppercase;
outline: 0;
color: #212121;
background: #ECECEC;
}
#menu li:hover a, #menu li.active a, #menu li.active span
{
}
#menu .current_page_item a
{
background: #E24E2A;
color: #FFF;
}
#menu .icon
{
}
Drop down menu:
#primary_nav_wrap
{
margin-top:15px
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul a
{
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:#f6f6f6
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary_nav_wrap ul ul li
{
float:none;
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
Thanks in advance!
Your navigation wrapper is menu whereas in the CSS from online it is primary_nav_wrap, so swap instances of these to menu.
In the html itself nested unordered list elements is used for the drop-downs, so add these under the list element where you need a drop-down.
Html:
<div id="menu">
<ul>
<li class="current_page_item">Home<ul>
<li>sub1</li>
<li>sub2</li>
<li>sub3</li>
</ul>
<li>Onze service</li>
<li>Ons team</li>
<li>Prijzen</li>
<li>Contact</li>
</ul>
</div>
CSS:
#menu ul {
display:inline-block;
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#menu li {
display:block;
float:left;
text-align:center;
line-height:60px
}
#menu li a,#menu li span {
display:inline-block;
margin-left:1px;
padding:0 1.5em;
letter-spacing:.1em;
text-decoration:none;
font-size:1em;
text-transform:uppercase;
outline:0;
color:#212121;
background:#ECECEC
}
#menu .current_page_item a {
background:#E24E2A;
color:#FFF
}
#menu {
margin-top:15px
}
#menu ul a {
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#menu ul li {
position:relative;
float:left;
margin:0;
padding:0
}
#menu ul li.current-menu-item {
background:#ddd
}
#menu ul li:hover {
background:#f6f6f6
}
#menu ul ul {
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#menu ul ul li {
float:none;
width:200px
}
#menu ul ul a {
line-height:120%;
padding:10px 15px
}
#menu ul ul ul {
top:0;
left:100%
}
#menu ul li:hover > ul {
display:block
}
Here is a jsfiddle of the code merged:
https://jsfiddle.net/o51pp5s6/

Adding drop down menu to a template via CSS

I downloaded a template for a website but it just has a basic menu, I need to add a dropdown.
Not sure what code you need, so let me know if I need to post more.
Here is the coding for the menu, I added a div class of "nav" based on a tutorial. So if I should do something entirely different let me know
<div class="menu">
<div class="nav">
<ul>
<li><span>Home</span></li>
<li><span>About us</span></li>
<li><span>2014 Chefs</span></li>
<li><span>Fund the Mission</span></li>
<li><span>Sponsors</span>
<ul>
<li><span>2014Sponsors</span></li>
</ul>
</li>
<li><span>Ambassador Family</span></li>
<li><span>Photos</span></li>
<li><span>Contact Us</span></li>
</ul></div>
</div>
Then this is the CSS coding, I figured most of it would be copied to my .nav so it has the same properties.
.menu { padding:0; margin:0; width:949px; height:58px; background:url(images/menu_bg.gif) top no-repeat;}
.menu ul { float:right; padding:0; margin:7px 30px 0 0; list-style:none; border:0;}
.menu ul li { float:left; margin:0; padding:0;}
.menu ul li a { float:left; margin:0 1px 0 0; padding:15px 0; color:#c8c8c8; font:normal 11px Arial, Helvetica, sans-serif; text-decoration:none;}
.menu ul li a span { padding:15px; margin:0; background:none;}
.menu ul li a:hover { color:#60b6ff; background:url(images/r_menu2.gif) no-repeat right;}
.menu ul li a:hover span { color:#60b6ff; background:url(images/l_menu.gif) no-repeat left;}
.menu ul li a.active { color:#60b6ff; background:url(images/r_menu.gif) no-repeat right;}
.menu ul li a.active span { color:#60b6ff; background:url(images/l_menu.gif) no-repeat left;}
.nav ul ul{
display: none;}
.nav ul li: hover> ul{
display: block;}
.nav ul li{
position: relative;
display: inline-block;
float:left;
padding:0;
margin:0px;;
list-style:none;
border:0;}
nav ul:after {
content: ""; clear: both; display: block;}
.nav ul li a { float:left; margin:0 1px 0 0; padding:15px 0; display:block; color:#c8c8c8; font:normal 11px Arial, Helvetica, sans-serif; text-decoration:none;}
.nav ul li a span { padding:15px; margin:0; background:none;}
.nav ul li a:hover { color:#60b6ff; background:url(images/r_menu2.gif) no-repeat right;}
.nav ul li a:hover span { color:#60b6ff; background:url(images/l_menu.gif) no-repeat left;}
.nav ul li a.active { color:#60b6ff; background:url(images/r_menu.gif) no-repeat right;}
.nav ul li a.active span { color:#60b6ff; background:url(images/l_menu.gif) no-repeat left;}

Drop Down Navigation Menu Only Block

HTML Code:
<div id="nav">
<div id="nav_wrapper">
<ul>
<li>
Admin <img src="" />
<ul>
<li>Adicionar Eventos</li>
<li>Actualizar Eventos</li>
<li>Eliminar Eventos</li>
</ul>
</li>
</ul>
</div>
</div>
CSS:
body{
padding:0;
margin:0;
overflow-y:scroll;
font-family:Arial;
font-size:18px;
}
#nav{
background-color:#333;
}
#nav_wrapper{
width:960px;
margin:0 auto;
text-align:left;
}
#nav ul{
list-style-type:none;
padding:0;
margin:0;
position:relative;
}
#nav ul li{
display:inline-block;
}
#nav ul li:hover{
background-color:#333;
}
#nav ul li img{
vertical-align:middle;
padding-left:5px;
}
#nav ul li a,visited{
color:#ccc;
display:block;
padding:15px;
text-decoration:none;
}
#nav ul li a:hover{
color:#ccc;
text-decoration:none;
}
#nav ul li:hover ul{
display:block;
}
#nav ul ul{
display:none;
position:absolute;
background-color:#333;
border: 5px solid #222;
border-top:0;
margin-left:-5px;
min-width:200px;
}
#nav ul ul li{
display:block;
}
#nav ul ul li a,visited{
color:#ccc;
}
#nav ul ul li a:hover{
color:#099;
}
I receive this: http://imgur.com/eMzuvfg
I want to put only Admin block visible and not the full header. Only one block black visible and in left side.
Someone can help me?
I think you want like this..
just replace the class from
#nav{
background-color:#333;
}
to
#nav{
width:100px;
background-color:#333;
}
Your question is confusing.. anyhow you need like this?
if no, please make your question little more detailed.
html
<div id="nav">
<div id="nav_wrapper">
<ul>
<li>
Admin <img src="" />
<ul>
<li>Adicionar Eventos</li>
<li>Actualizar Eventos</li>
<li>Eliminar Eventos</li>
</ul>
</li>
</ul>
</div>
</div>
css
body{
padding:0;
margin:0;
overflow-y:scroll;
font-family:Arial;
font-size:18px;
}
#nav{
background-color:#333;
}
#nav_wrapper{
float:left;
margin:0 auto;
text-align:left;
background-color:#333;
}
#nav ul{
list-style-type:none;
padding:0;
margin:0;
position:relative;
}
#nav ul li{
display:inline-block;
}
#nav ul li:hover{
background-color:#333;
}
#nav ul li img{
vertical-align:middle;
padding-left:5px;
}
#nav ul li a,visited{
color:#ccc;
display:block;
padding:15px;
text-decoration:none;
}
#nav ul li a:hover{
color:#ccc;
text-decoration:none;
}
#nav ul li:hover ul{
display:block;
}
#nav ul ul{
display:none;
position:absolute;
background-color:#333;
border: 5px solid #222;
border-top:0;
margin-left:-5px;
min-width:200px;
}
#nav ul ul li{
display:block;
}
#nav ul ul li a,visited{
color:#ccc;
}
#nav ul ul li a:hover{
color:#099;
}

Drop down menu keeps jumping to the right

Some how my drop down menu keeps jumping to the right instead of dropping down right underneath it's parent.
I've tried positioning it but that doesn't work since the position changes when the browserwindow changes size.
How do I get my drop down menu centered underneath the parent?
Html:
<div id="topnav">
<ul>
<li>CONTACT</li>
<li>BLOG</li>
<li>OVER ONS</li>
<li>GEDRAGSBEINVLOEDING</li>
<li>ONZE DIENSTEN
<ul>
<li class="topmargin">ONDERZOEK</li>
<li>ADVIES</li>
<li>LEZINGEN</li>
</ul>
</li>
<li>HOME</li>
</ul>
</div>
</div>
CSS:
#topnav { z-index:3;
padding-top:76px; }
#topnav ul li { list-style-type:none;
display:inline;
float:right;
}
#topnav ul li a { font-family:Arial, Helvetica, sans-serif;
font-size:13px;
font-weight:bold;
text-decoration:none;
padding-left:15px;
}
#topnav ul li a:link { color:#00aeef; }
#topnav ul li a:visited { color:#00aeef; }
#topnav ul li a:active { color:#f26532; }
#topnav ul li a:hover { color:#f26532; }
#topnav ul li a:focus { color:#f26532; }
#topnav li ul { position:absolute;
left:-999em;
list-style-type:none;
}
#topnav li ul li { border-top:0px;
clear:both;}
#topnav li:hover ul { left:auto; }
#topnav li:hover ul li { float:none;
display:block;
width:100%;
}
#topnav ul li ul li { text-align:center;
padding:10px 12px 10px 0px;
border-top:#FFF solid;
background-color:#00aeef;
width:120px;
}
.topmargin { margin-top:5px; }
#topnav li ul li a { font-family:Arial, Helvetica, sans-serif;
font-size:13px;
font-weight:bold;
text-decoration:none;
padding-left:14px;
}
#topnav li ul li a:link { color:#FFF; }
#topnav li ul li a:visited { color:#FFF; }
#topnav li ul li a:active { color:#FFF; }
#topnav li ul li a:hover { color:#f26532; }
#topnav li ul li a:focus { color:#FFF; }
Change #topnav id to this
#topnav{
z-index:3;
padding-top:76px;
width:800px;
and add the folling id#topnav ul{
float:left;
}
#topnav li:hover ul
{left:80px;}
You can add this in or change your css
#topnav li:hover ul {
left: auto;
margin-left: -30px;
}
or
#topnav li ul {
left: auto;
list-style-type: none;
position: absolute;
padding: 0px;
}
Your nested ul tag seems to have some unnecessary padding applied by the user-agent stylesheet.
Try using:
#topnav li ul {padding: 0px;}
This way the padding of only the nested ul element will be affected.

Large results in CSS Menu leading to distortion

This is the CSS Used. What im doing is giving hover to the main UL and then Hiding the Li,
and some coloring for beautifying purpose
.preload1 {background: url(/ncbeonline/image/dbintranet/untitled.gif);}
.preload2 {background: url(/ncbeonline/image/dbintranet/images.gif);}
.preload3 {background: url(/ncbeonline/image/dbintranet/gear_icon.gif);}
#nav {padding: 0; margin:0; list-style:none; height:0px; width:31px; background:black; position:relative; z-index:500; font-family:arial, verdana, sans-serif;}
#nav li.top {display:block; }
#nav li a.top_link {display:block; height:14px; line-height:15px;
width:11px; color:black; text-decoration:none; font-size:9px; font-weight:bold; padding:0 0 0 0px; cursor:pointer;}
#nav li a.top_link span {display:block; padding: 0; height:14px;width:31px; color:#CFDAEB;}
#nav li a.top_link span.down { display:block; padding: 0; height:14px; width:31px;color:#CFDAEB;}
#nav li a.top_link:hover {color:black; color: #CFDAEB;}
#nav li a.top_link:hover span {color:#CFDAEB;}
#nav li a.top_link:hover span.down {color:#CFDAEB;}
#nav li:hover > a.top_link {color:black; color: #CFDAEB;}
#nav li:hover > a.top_link span {color:#CFDAEB;}
#nav li:hover > a.top_link span.down {color:#CFDAEB;}
/* Default list styling */
#nav li:hover {position:relative; z-index:200;}
/* keep the 'next' level invisible by placing it off screen. */
#nav ul,
#nav li:hover ul ul,
#nav li:hover ul li:hover ul ul,
#nav li:hover ul li:hover ul li:hover ul ul,
#nav li:hover ul li:hover ul li:hover ul li:hover ul ul
{position:absolute; top:-9999px; width:0; height:0; margin:0; padding:0; list-style:none;}
#nav li:hover ul.sub
{right:0; top:16px; background: yellow; padding:3px; border:1px solid #5a5aff; white-space:nowrap; width:200px; height:auto; z-index:300;}
#nav li:hover ul.sub li
/** big box*/
{display:block; height:20px; position:relative; float:right; width:200px; font-weight:normal;}
#nav li:hover ul.sub li a
/* for bg color*/
{display:block; font-size:14px; height:20px; width:200px; line-height:20px; text-indent:5px; color:#000; text-decoration:none;}
#nav li ul.sub li a.fly
{background:yellow;}
#nav li:hover ul.sub li a:hover
{background:#5a5aff; color:yellow;}
#nav li:hover ul.sub li a.fly:hover
{background:#5a5aff; color:yellow;}
#nav li:hover ul li:hover > a.fly {background:#5a5aff; color:yellow;}
#nav li:hover ul li:hover ul,
#nav li:hover ul li:hover ul li:hover ul,
#nav li:hover ul li:hover ul li:hover ul li:hover ul,
#nav li:hover ul li:hover ul li:hover ul li:hover ul li:hover ul
{right:90px; top:-4px; background: yellow; padding:3px; border:1px solid #5a5aff; white-space:nowrap; width:90px; z-index:400; height:auto;}
HTML part for generating the Menus. This is a simple menu with 4 options with a onclick event attached for navigation purpose
<ul id="nav">
<li class="top"><a href="#nogo53" id="shop" class="top_link"><span class="down">
<img src="/ncbeonline/image/dbintranet/gear_icon.gif"
width="20px" height="20px" align="right" /></span></a>
<ul class="sub">
<li><a onclick="pageSubmit(${referenceId});
$('PRODUCT').action=
$('PRODUCT').action.gsub('ProductList/list.xhtml','ProductListDetail
/historyList.xhtml');
document.getElementById('PRODUCT').submit();">-View Product
</a></li>
<li><a onclick="pageSubmit(${referenceId});
$('PRODUCT').action=$('PRODUCT').action.gsub('ProductList/list.xhtml','ProductListDetail /edit.xhtml');
document.getElementById('PRODUCT').submit();">-Edit Product </a></li>
<li><a onclick="pageSubmit(${referenceId});
$('PRODUCT').action=$('PRODUCT').action.gsub('ProductList/list.xhtml','ProductListDetail/copy.xhtml');
document.getElementById('PRODUCT').submit();">-Copy Product </a></li>
<li><a onclick="pageSubmit(${referenceId});
$('PRODUCT').action=$('PRODUCT').action.gsub('ProductList/list.xhtml','ProductListDetail/addNewChildParent.xhtml');
document.getElementById('PRODUCT').submit();">-Add Child Product </a></li>
<s:if test='%{approvalStatus neq "A"}'>
<li><a onclick="pageSubmit(${referenceId});
$('PRODUCT').action=$('PRODUCT').action.gsub('ProductList/list.xhtml','ProductListDetail/deleteView.xhtml');
document.getElementById('PRODUCT').submit();">-Delete Draft </a></li>
</s:if>
<s:elseif test='%{approvalStatus eq "A"}'>
<li><a onclick="pageSubmit(${referenceId});
$('PRODUCT').action=$('PRODUCT').action.gsub('ProductList/list.xhtml','ProductListDetail/deleteView.xhtml');
document.getElementById('PRODUCT').submit();">-Delete Product </a></li>
</s:elseif>
</ul>
</li>
</ul>