submenu wont align to the menu when hovered - css

I'm having some problem with my menu and submenu when i hover on my menu the submenu wont align when hovered it floats on the left then show on the bottom of the first menu so when I select the last menu I cant select it. here's the reference picture.
http://prntscr.com/4trok1
HTML ( WORDPRESS )
<section class="twelve columns clearfix" style="background:transparent">
<div id="navcontainer">
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' => 'header-menu' ) ); ?></div>
</section>
CSS:
.menu {
width:auto;
float:left;
display:block;
}
.children {
display:none;
}
#navcontainer {
display:inline;
padding:0px;
margin: 0px; /*-8px 0 0 10px;*/
list-style:none;
position:relative;
z-index:1;
float:left;
height: 20px;
}
#navcontainer ul {
margin: 0;
padding: 0;
list-style-type: none;
text-align: left;
}
#navcontainer ul li {
display: block;
float: left;
}
#navcontainer ul li a {
text-decoration: none;
padding: .2em 1em;
color: #b37032;
background-color: #dbd2c1;
width: 100%;
}
#navcontainer ul li ul li{
display:block;
width:auto;
float: none;
background:#edebd7;
}
#navcontainer ul li ul li a {
background: transparent !important;
color: #724e32;
border-top: 0px !important;
border-left: 0px !important;
border-right: 0px !important;;
-moz-border-radius: 0 0 0 0 !important;;
-webkit-border-radius: 0 0 0 0 !important;;
border-radius: 0 0 0 0 !important;;
background-color: transparent !important;;
opacity: 1 !important;;
}
#navcontainer li:hover ul{
display:block;
}
#navcontainer ul li:hover a {
color: #724e32;
border-top: 1px solid #694b0a;
border-left: 1px solid #694b0a;
border-right: 1px solid #694b0a;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
background-color: #edebd7;
opacity: 0.5;
}
#navcontainer ul li a:hover {
color: #fff;
background-color: #d3c096;
}
#navcontainer li:hover ul.children {
left:0;
top:18px;
background:#edebd7;
color:#724e32;
padding:5px;
position:absolute;
border-left:1px solid #694b0a;
border-right:1px solid #694b0a;
border-bottom:1px solid #694b0a;
white-space:nowrap;
width:160px;
height:auto;
z-index:300;
-moz-border-radius:0 0 5px 5px;
-webkit-border-radius:0 0 5px 5px;
border-radius:0 0 5px 5px;
}
#navcontainer ul li ul li:hover {
color: #fff;
background-color: #d3c096;
}
#navcontainer ul li ul li a:hover {
color: #fff;
background-color: #d3c096;
}
#navcontainer ul li ul li:hover a{
color: #fff;
background-color: transparent;
}

replace this class in your css file and everything should be fine:
#navcontainer li:hover ul.children {
top:18px;
background:#edebd7;
color:#724e32;
padding:5px;
position:absolute;
border-left:1px solid #694b0a;
border-right:1px solid #694b0a;
border-bottom:1px solid #694b0a;
white-space:nowrap;
width:160px;
height:auto;
z-index:300;
-moz-border-radius:0 0 5px 5px;
-webkit-border-radius:0 0 5px 5px;
border-radius:0 0 5px 5px;
}
the left:0 propriety was the problem. Nothing else :)

Related

How to center navigation bar in UL?

Tried display: inline-block; text-align: center; and many things from the Internet, but nothing helped.
#nav{
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none;
background-color: #C9C9C9;
border-bottom: 5px solid #ddd;
border-top: 1px solid #ccc; }
#nav li {
list-style: none;
float: left; }
#nav li a {
display: block;
padding: 5px 5px;
font-size: 13px;
text-decoration: none;
color: #000;
border-right: 1px solid #ccc; }
#nav li a:hover {
color: #fff;
background-color: #000;
-moz-border-radius: 3px; -webkit-border-radius: 3px; -khtml-border-radius: 3px; border-radius: 3px; }
HTML:
<ul id="nav">
<?php wp_nav_menu('menu=header_menu&container=false'); ?>
<div class="clear"></div>
</ul>
It looks like this:
... and I don't know how to center it.
basic is :
ul {
margin:0;
padding:0;
list-style-type:none;
text-align:center;
}
li {
display:inline-block;
}
Note that if <li> floats, you lose :)
http://jsfiddle.net/KWG2j/
then , if you need to center ul with fluid width: go one step higher in html.
http://jsfiddle.net/KWG2j/1
nav {
text-align:center;
}
nav ul {
margin: 0;
padding: 0;
display:inline-block;
list-style: none;
background-color: #C9C9C9;
border-bottom: 5px solid #ddd;
border-top: 1px solid #ccc;
}
nav li {
display:inline-block;
}
nav li a {
display: block;
padding: 5px 5px;
font-size: 13px;
text-decoration: none;
color: #000;
border-right: 1px solid #ccc;
}
#nav li a:hover {
color: #fff;
background-color: #000;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
border-radius: 3px;
}
Set a fixed width on your UL, then adjust it's margin as
margin: 0 auto;
This will apply equal margins to both the left and right of block elements that have a definite width.
http://jsfiddle.net/Be4Q2/
#nav {
margin: 0;
padding: 0;
text-align:center;
list-style: none;
background-color: #C9C9C9;
border-bottom: 5px solid #ddd;
border-top: 1px solid #ccc;
}
#nav li {
display:inline-block;
}
#nav li a {
display: block;
padding: 5px 5px;
font-size: 13px;
text-decoration: none;
color: #000;
border-right: 1px solid #ccc;
}
#nav li a:hover {
color: #fff;
background-color: #000;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
border-radius: 3px;
}
<ul id="nav">
<li>Home</li>
<li>Projects</li>
<li>Contact</li>
<li>About</li>
<div class="clear"></div>
</ul>

CSS Drop down menu not working for ie8 and flashing shut on iPhone 5 browser

Humans needed... My CSS drop down menu will not show up in ie8 and flashes then shuts on iPhone 5 browsers (responsive design)..using code from a themeforest template. without further adieu here is the code.
HTML
<div id="navigation">
<ul>
<li>Home</li>
<li>About
<ul>
<li>Leadership</li>
<li>Giving</li>
<li>Careers</li>
<li>Contact</li>
</ul>
</li>
</ul>
</div>
CSS
/* Main Navigation
==========================*/
#navigation {
float: right;
}
#navigation ul, #navigation li {
list-style:none;
padding:0;
margin:0;
display:inline;
}
#navigation ul li{
float:left;
position:relative;
}
#navigation ul li a {
font-family: Arial, sans-serif;
display: inline-block;
color: #888;
padding: 40px 6px 10px 6px;
margin: 0 5px;
text-decoration: none;
font-size: 14px;
border-bottom: 3px solid transparent;
}
#navigation ul li a:hover{
border-bottom: 3px solid #555;
}
#navigation ul ul {
opacity: 0;
margin: -3px 0 0 5px;
filter: alpha(opacity=0);
position: absolute;
top:-99999px;
left: 0;
background: #fff;
border: 1px solid #dddddd;
border-top: 3px solid #555;
z-index: 999;
}
#navigation ul ul li a:hover {
border-bottom: 1px solid #ddd;
}
#navigation ul ul li a {
padding: 8px 0;
display: block;
width: 130px;
margin: 0 16px;
font-family: Arial, sans-serif;
font-weight: normal;
font-size: 12px;
border-bottom: 1px solid #dddddd;
border-top: 1px solid transparent;
}
#navigation ul ul ul {
position:absolute;
top:-99999px;
left:100%;
opacity: 0;
margin: -3px 0 0 0;
z-index: 999;
}
#navigation ul ul ul li a {
border-bottom: 1px solid #dddddd !important;
border-top: 1px solid transparent;
}
#navigation ul ul li:last-child a, #navigation ul ul li:last-child a:hover {
border-bottom: 1px solid transparent
}
#navigation ul ul ul li:last-child a {
border-bottom: 1px solid transparent !important
}
#navigation ul li:hover>ul{
opacity: 1;
position:absolute;
top:99%;
left:0;
}
#navigation ul ul li:hover>ul{
position:absolute;
top:0; left:100%;
opacity: 1;
z-index:497;
background: #fff border: 0;
}
#navigation ul li:hover > a {
color: #444;
}
#navigation ul ul li:hover > a {
border-top: 1px solid transparent;
color: #444;
}
#current {
font-weight: bold !important;
color: #444 !important;
border-bottom: 3px solid #555 !important;
}
Your problem appears to be with the line:
filter: alpha(opacity=0);
To get this to work in IE8, you need to include the line:
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; /*IE8*/
Alternatively, removing the line entirely doesn't seem to break anything. You might need to play around with different browsers and see what happens.
There's a more in-depth discussion on opacity in IE8 here: Opacity in web pages?
I'm afraid I can't help you on the iPhone side of things.
You also appear to have a bug in your code:
#navigation ul ul li:hover>ul{
position:absolute;
top:0; left:100%;
opacity: 1;
z-index:497;
background: #fff border: 0;
}
You're missing a semi colon after #fff on the last line. Use the W3C CSS Validator to help you trap bugs like this.

How to center a superfish sub-menu under it's parent?

I have a superfish menu on my site.
I am trying to find a way to center the sub-menu under it's parent. Right not the sub-menu is aligned left.
My website
My menu css:
/* Custom Styles */
.sf-menu { float:left }
/* 1st level links, no hover, no visits */
.sf-menu li {
}
.sf-menu li a {
color:#3E4245;
line-height:18px;
text-decoration:none;
text-shadow:0 1px 0 #fff;
margin:0;
padding:6px 12px;
}
/* 1st level links, hover */
.sf-menu li a:hover {
color: #7B9EBB
}
/* 1st level links, while hovering over sub menu */
.sf-menu li.sfHover a {
color:#7B9EBB
}
/* 1st level current page */
.sf-menu .current-menu-item a {
color: #7B9EBB;
}
.sf-menu .current-menu-item {
background:#fefefe;
border: 1px solid #ddd;
border-color: rgba(0,0,0,.15);
border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;
background: #f5f5f5;
background: -moz-linear-gradient(100% 100% 90deg, #f5f5f5, #fff);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#f5f5f5));
-moz-box-shadow: 0 1px 1px rgba(0,0,0,.03);
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.03);
box-shadow: 0 1px 1px rgba(0,0,0,.03);
}
/* 1st level down triangles with pure css*/
.sf-menu li .sf-sub-indicator {
}
/* Drop-down */
.sf-menu li ul {
background: #fff; margin:5px 0 0; padding:10px 0 0; position: absolute; left: -999em; width: 180px; border: 1px solid #e3e3e3; z-index:9999;
}
.sf-menu li ul, .sf-menu li ul ul {
background: #FFF;
border: 1px solid #e3e3e3;
/* Border Radius */
border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;
/* Box Shadow */
-moz-box-shadow: 0 2px 2px rgba(0,0,0,.03);
-webkit-box-shadow: 0 2px 2px rgba(0,0,0,.03);
box-shadow: 0 2px 2px rgba(0,0,0,.03);
margin: 0;
padding:10px 0 0 0;
}
.sf-menu li ul ul { border-radius: 0 4px 4px 4px; -moz-border-radius: 0 4px 4px 4px; -webkit-border-radius: 0 4px 4px 4px; }
.sf-menu li ul ul {
margin-top: -1px
}
.sf-menu li li, .sf-menu li li li {
border:0;
border-bottom: 1px solid #dedede
}
.sf-menu li li:last-child, .sf-menu li li li:last-child {
border-bottom: none
}
.sf-menu li li a, .sf-menu li li li a {
padding: 8px 15px;
color: #666 !important;
font-size: 0.8em;
}
.sf-menu li li a:hover, .sf-menu li li li a:hover {
font-weight: bold;
}
/* Drop-down Arrow */
.sf-menu li li:first-child {
background: url('../images/nav-indicator.png') no-repeat scroll center top transparent;
margin-top: -18px;
padding-top: 10px
}
.sf-menu li li li:first-child { background: none }
I would suggest using a negative left parameter on line 29 of your superfish css file.
.sf-menu li#menu-item-34:hover ul,
.sf-menu li#menu-item-34.sfHover ul {
left: -48px;
}
.sf-menu li#menu-item-21:hover ul,
.sf-menu li#menu-item-21.sfHover ul {
left: -64px;
}
.sf-menu li#menu-item-20:hover ul,
.sf-menu li#menu-item-20.sfHover ul {
left:4px;
}
In SUPERFISH JS onshow:
var $this = this.addClass(o.hoverClass),
$ul = $this.children(o.popUpSelector);
var mainbtn_w = this.width()/2;
var sub_w = $ul.width()/2;
$ul.css('left', "-"+(sub_w-mainbtn_w)+"px");

How to display white background overflow on dropdown menu?

I have a drop down menu created purely with CSS. I would like to implement an overflow using z-index (i presume) that will bleed over a border on my menu to give the impression that both the link and the dropdown menu are joined.
The drop down works correctly but I need the first menu item to overflow it's white background on to the drop down menu.
If you go to http://cssdesk.com/ztK64 and hover over the first menu link you will see what I am attempting to explain.
This is my code:
CSS
/*Main nav*/
.main_nav_container{
margin: 10px 0 10px 0;
float:right;
}
ul.main_nav{
margin:0;
z-index:1;
postion:absolute;
}
ul.main_nav li{
margin:0;
display:inline-block;
border-top:solid 1px transparent;
border-left:solid 1px transparent;
border-right:solid 1px transparent;
}
ul.main_nav li a{
font-size:13px;
display:block;
font-weight:bold;
height:25px;
line-height:25px;
padding:0 13px;
text-decoration:none;
color:#1122cc;
border:1px solid transparent;
}
ul.main_nav li a:hover{
text-decoration:underline;
}
ul.main_nav li:hover{
border-top:solid 1px #ccc;
border-left:solid 1px #ccc;
border-right:solid 1px #ccc;
-moz-border-radius: 4px 4px 0 0;
border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
-khtml-border-radius: 4px 4px 0 0;
background: #fff;
}
ul.main_nav li:hover ul{
display:inline;
}
ul.main_nav li ul{
display:none;
z-index:500;
position:absolute;
background: #fff;
margin:0;
padding:0;
border:solid 1px #ccc;
-moz-border-radius: 0 4px 4px 4px;
border-radius: 0 4px 4px 4px;
-webkit-border-radius: 0 4px 4px 4px;
-khtml-border-radius: 0 4px 4px 4px;
}
ul.main_nav li ul li{
display:block;
margin:0;
padding:0;
text-align:left;
}
ul.main_nav li ul li:hover{
text-decoration:underline;
border-top:solid 1px #fff;
border-left:solid 1px #fff;
border-right:solid 1px #fff;
}
ul.main_nav li ul li a{
font-weight:normal;
}
HTML
<div class="main_nav_container">
<ul class="main_nav">
<li>
<a id="hover" href="#">For sale</a>
<ul>
<li>Property for sale</li>
<li>New homes for sale</li>
<li>Find estate agents</li>
</ul>
</li>
<li>To rent</li>
<li>New homes</li>
<li>House prices</li>
<li>Blog</li>
<li>Property advice</li>
<li>Contact</li>
</ul>
</div>
Add the following CSS:
ul.main_nav li:hover a {
border-bottom:1px solid white;
position:relative;
z-index:100;
}
ul.main_nav li:hover ul {
margin-top:-1px;
margin-left:-1px;
z-index:99;
}
You have to have the position:relative; in the a to make the z-index work correctly. The bottom border of the a is to cover up the border of the ul. The margin changes in the ul are to position the borders correctly for the effect of them being connected.

Help me with the CSS of IE

I am having a problem with my website, www.diaplasisgym.com. The problem is the sub menu. It is working fine in Firefox, Chrome and Safari, but if you open it with IE the slide bar is hiding the submenu. How i can fix this?
Here the code of the menu and submenu:
#mainMenu {
position:absolute;
bottom:-80px;
left:0px;
background:url(images/menu.png) no-repeat;
width: 961px;
height:98px;
}
#mainMenu ul li {
float:right;
height:70px;
}
#mainMenu ul li a {
font-weight:bold;
display:block;
color:#ffffff;
padding:25px 20px 0;
font-size:15px;
}
#mainMenu ul li a span {
font-size:10px;
color:#999;
}
#mainMenu ul li a:hover {
text-decoration:none;
color:#2fc8ff;
}
#mainMenu.ddsmoothmenu ul{
margin: 0;
padding: 0;
list-style-type: none;
}
/*Top level list items*/
#mainMenu.ddsmoothmenu ul li {
position: relative;
display: inline;
float: left;
}
/*Top level menu link items style*/
* html #mainMenu.ddsmoothmenu ul li a{ /*IE6 hack to get sub menu links to
behave correctly*/ display:
inline-block;
}
/*1st sub level menu*/
#mainMenu.ddsmoothmenu ul li ul{
position: absolute; l
eft: 0;
display: none; /*collapse all sub menus to begin with*/ visibility: hidden;
width:auto;
padding-bottom:7px;
background:
url(images/secondarydropdown.png)
repeat-y; box-shadow: 3px 6px 7px 1px
rgba(0, 0, 0, 0.5);
-moz-box-shadow:3px 6px 7px 1px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 3px 6px 7px 1px rgba(0, 0, 0, 0.5);
border-radius:8px;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-top-left-radius: 0px;
-moz-border-radius-topleft: 0px;
-webkit-border-top-left-radius: 0px;
border-top-right-radius: 0px;
-moz-border-radius-topright: 0px;
-webkit-border-top-right-radius: 0px;
border: 1px solid #232323;
border-top:none; /*border-bottom:1px solid #222;*/
}
/*Sub level menu list items (undo
style from Top level List Items)*/
#mainMenu.ddsmoothmenu ul li ul li{
float: none;
display: list-item;
padding:0;
height:3%;
}
/* Sub level menu links style */
#mainMenu.ddsmoothmenu ul li ul li a, #mainMenu.ddsmoothmenu ul li ul li a:hover{
text-align:left;
/*background:#000;*/
line-height:20%;
font-size:13px;
padding: 22px 5px 15px 28px;
color: #ffffff;
font-family:
Century Gothic, Arial, sans-serif;
text-shadow: 1px 1px 1px rgba(0, 0, 0,0.3);
background: url(images/secondary-dropdown-bullet.png)
no-repeat 15px 20px; z-index:9999;
}
#mainMenu.ddsmoothmenu ul li ul li a:hover {
color:#1FA2E1;
}
#mainMenu.ddsmoothmenu ul li ul li a.last, #mainMenu.ddsmoothmenu ul li
ul li a.last:hover {
border:none;
}
/* Holly Hack for IE \*/
* html #mainMenu.ddsmoothmenu{
height: 1%;
} /*Holly Hack for IE7 and below*/
Here's the answer for IE 7
paste this in your stylesheet
/* IE 7 Fix */
#header{z-index:1001 !important;}
#content{z-index:100 !important;}

Resources