Large results in CSS Menu leading to distortion - html

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>

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/

Changing the look of my dropdown menu

jsfiddle of the look I'm trying to incorporate: http://jsfiddle.net/kUHNJ/
jsfiddle of where I'm currently standing: http://jsfiddle.net/5gTML/
I don't know what I'm doing wrong anymore. I'm assuming that some of the inline-blocks should be blocks and vice -versa but I'm really unsure.
Filler code
change your css with this
.main-header nav{
background-color:#333333;
height:40px;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
.main-header nav ul{
list-style: none;
margin: 0 auto;
padding:0;
height:40px;
list-style-type:none;
list-style-position:outside;
position:relative;
line-height:2.5em;
width:100%;
background-color:#333;
display:inline-block;
}
.main-header nav ul a:link, .main-header nav ul a:active, .main-header nav ul a:visited{
display:block;
padding:0px 5px;
color:#fff;
text-decoration:none;
background-color:#333;
width:100%;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
.main-header nav ul a:hover{
background-color:#bc9c98;
text-shadow: none;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
.main-header nav ul ul a:link, .main-header nav ul ul a:active, .main-header nav ul ul a:visited{
width:100%
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
.main-header nav ul li{
float:left;
position:relative;
}
.main-header nav ul ul {
position:absolute;
top:2.5em;
left:-2.5em;
list-style-type:none;
list-style-position:outside;
line-height:2.5em;
display:none;
width:100%;
}
.main-header nav ul ul li{
display:inline-block;
width:100%;
}
.main-header nav ul li ul a{
float:left;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
.main-header nav ul ul ul{
top:auto;
}
.main-header nav ul li ul ul {
position:absolute;
top:auto;
left:100%;
margin:0px 0 0 -2em;
}
.main-header nav ul li:hover ul ul, .main-header nav ul li:hover ul ul ul, .main-header nav ul li:hover ul ul ul ul{
display:none;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
.main-header nav ul li:hover ul, .main-header nav ul li li:hover ul, .main-header nav ul li li li:hover ul, .main-header nav ul li li li li:hover ul{
display:block;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
it works..good luck!!!!

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.

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

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.

Dropdown navigation menu bar is working in IE7 but not in FireFox

I have a dropdown bar -
<div class="buttonContainer">
<ul>
<li>
<a class="menu1one" href="">Dashboard</a>
</li>
</ul>
<ul>
<li>
<div class="noLink">Tasks</div>
<ul>
<li>View</li>
<li>Edit</li>
<!--[if lte IE 6]></a><![endif]-->
</ul>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li>
<div class="noLink">Dictionaries</div>
<ul>
<li>Needs</li>
<li>Activities</li>
</ul>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li>
<div class="noLink">Admin</div>
<ul>
<li>User Accounts</li>
</ul>
<!--[if lte IE 6]></a><![endif]-->
</li>
</ul>
</div>
CSS -
/*dropdown menu*/
.menu { float:left; width:100%; font-family: arial; border-top:1px solid #4c597f; background-color: #1079b5; min-width:950px; }
.menu .buttonContainer { padding:0 0 0 200px; }
.menu ul { padding:0; margin:0; list-style-type:none; }
.menu ul li { margin:0; float:left; position:relative; background-color:#153d71; }
.menu ul li a, .menu ul li a:visited { float:left; display:block; text-decoration:none; color:#ddf; padding:0px 16px; line-height:25px; height:30px; }
.menu ul li a:hover { background-color:#9fc1ed; color: #153d71;}
.noLink { display:block; color:#ddf; padding:0px 16px; line-height:25px; height:30px; }
.menu ul li:hover { width:auto; }
.menu ul li ul { display: none; }
/* specific to non IE browsers */
.menu ul li:hover ul { display:block; position:absolute; top:30px; left:0; width:154px; border-bottom:1px solid #000; }
.menu ul li:hover ul.endstop { left:-92px; }
.menu ul li:hover ul li ul { display: none; }
.menu ul li:hover ul li a { display:block; background:#1079b5; color:#000; height:auto; line-height:15px; padding:4px 16px; width:120px; border:1px solid #000; border-bottom:0; }
.menu ul li:hover ul li a.drop { background:#ccd no-repeat 3px 8px; }
.menu ul li:hover ul li a:hover { background-color: #153d71; color: #FFFFFF; }
.menu ul li:hover ul li a:hover.drop { background: #ccd no-repeat 3px 8px; }
.menu ul li:hover ul li:hover ul { display:block; position:absolute; left:153px; top:-1px; }
.menu ul li:hover ul li:hover ul.left { left:-153px; }
/* IE6 */
.menu ul li a:hover ul { display:block; position:absolute; top:30px; t\op:33px; background:#153d71; left:0; border-bottom:1px solid #000; }
.menu ul li a:hover ul.endstop { left: -92px; }
.menu ul li a:hover ul li a { display:block; background:#153d71; color:#000; height:1px; line-height:15px; padding:4px 16px; width:154px; w\idth:120px; border:1px solid #000; border-bottom:0; }
.menu ul li a:hover ul li a.drop { background:#ccd url('') no-repeat 3px 8px; padding-bottom:4px; }
.menu ul li a:hover ul li a ul { visibility:hidden; position:absolute; height:0; width:0; }
.menu ul li a:hover ul li a:hover { color:#000; background: #ccd url('') no-repeat 3px 8px; }
.menu ul li a:hover ul li a:hover.drop { background: #ccd url('') no-repeat 3px 8px; }
.menu ul li a:hover ul li a:hover ul { visibility:visible; position:absolute; top:0; color:#000; left:153px; }
.menu ul li a:hover ul li a:hover ul.left { left:-153px; }
The dropdown menu is working well or showing up on hover in IE7 but not responding in Firefox.
Could anybody help me with this please?? I tried position : relative for inner li a:hover and it shows the menu but extends the whole div till its end. What is to be changed here?
Also, i don't want to use javascript/jquery for this.
-thanks
EDITED - I have found the solution to get it to work. I added 'position: absolute;' attribute to the .menu{} in the css. That made it work... Thanks.
I just tested on IE7 its working fine to me
http://jsfiddle.net/vcN5g/
I have found the solution to get it to work. I added 'position: absolute;' attribute to the .menu{} in the css. That made it work... Thanks.