Wordpress menu structure change in css file - wordpress

I have used the wordpress twenty eleven theme for my website. Now i want to crate a dropdown menu for my site. By default wordpress have the dropdown menu facility. Now when i hover on the main menu i got the sub-menu part. For example :-
I have a main menu like :-
Home | About | Contact
When i hover on the about menu it show the sub menus of "about" menu like
Home | About | Contact
Our Services
History
Our Staff
when i hover on the history menu it display the sub menu of History Menu like bellow:-
Home | About | Contact
Our Services
History
History 1
History 2
History 3
Our Staff
but i want to display the submenu of History, when i hover on About menu. If i hover on the About menu it should display like bellow :-
Home | About | Contact
Our Services
History
History 1
History 2
History 3
Our Staff
Please help me to get the output in the wordpress menu.
#access {
background: #00ADEE; /* Show a solid color for older browsers */
clear: both;
display: block;
width: 915px;
}
#access ul {
font-size: 11px;
list-style: none;
margin: 0;
padding: 0;
}
#access li {
float: left;
position: relative;
}
#access a {
color: #eee;
display: block;
line-height: 12px;
padding: 4px 9px;
text-decoration: none;
background: url(images/menu-border.png);
background-position: right 6px;
background-repeat: no-repeat;
text-transform: lowercase;
}
#access ul ul {
display: none;
float: left;
margin: 0;
position: absolute;
left: 11px;
width: 252px;
z-index: 99999;
background: #FFFFFF;
padding: 0 4px;
border: 1px solid #00AEEF;
}
#access ul ul li {
}
#access ul ul ul {
left: 23%;
top: 0;
border: none;
width: 150px;
}
#access ul ul ul li{
border: none;
width: 112px;
background:url(images/list.png);
background-position: 0 10px;
background-repeat: no-repeat;
background-color: #FFF;
width: 185px;
}
#access ul ul ul a{
border: none;
background: transparent;
}
.sub-menu .menu-item-object-custom a:hover{
height: 40px;
}
#access ul ul a {
border-bottom: 1px solid #BCBEC0;
color: #000;
font-size: 10px;
font-weight: normal;
height: auto;
line-height: 1.4em;
padding: 5px 7px;
width: 237px;
}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
color: #000;
}
#access ul ul > a {
color: #000;
}
#access li:hover > a,
#access a:focus {
color: #FFFFFF;
}
#access ul li:hover > ul {
display: block;
}
#access ul ul .current_page_item > a {
color: #00ADEE;
font-weight: bold;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a {
color: #FFFFFF;
}

Basically, you need to find the rule where there is a :hover defined on a li element. It usually goes like this:
li:hover ul {
display: block;
}
for the second level menu to be visible, you'd need to add something like the following:
li:hover ul ul {
display: block;
}
This is just how it should be in theory, I'd need to see the part of the CSS that describes the menu so I could tell you an exact change to make.

Related

Shifting un ordered list items to the left ( Wordpress )

Hi I am having trouble shifting a menu list on my wordpress site to the left. It appears as if there is a margin so when the list contains so many items it appears right offset and no longer centred. The site in question is www.cabinboys.ca the menu I'm talking about is right below the cabinboys image filled with two letter items. If any one could look at my css and see if they could figure out how to shift the list items to the left that would be much appreciated thanks.
/* =Menu
----------------------------------------------- */
#menu {
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
margin-bottom: 25px;
padding: 10px;
text-align: right;
width: 800px;
}
#menu img {
margin-bottom: 10px;
}
#menu a {
color: #666;
font-family: 'Oswald', Helvetica, Arial, sans-serif;
font-size: 18px;
margin: 0 10px;
text-decoration: none;
text-transform: uppercase;
}
#menu a:hover {
color: #36bcab;
}
#menu ul {
list-style: none;
margin: 0;
padding-left: 30;
}
#menu li {
float: right;
position: relative;
}
#menu ul ul {
display: none;
float: right;
position: absolute;
right: 0;
z-index: 99999;
}
#menu ul ul ul {
right: 100%;
top: 0;
}
#menu ul ul a {
background: #e9e9e9;
border-bottom: 1px solid #e1e1e1;
display: block;
font-size: 14px;
height: auto;
line-height: 1em;
margin: 0 ;
padding: .8em .5em .8em 1em;
width: 130px;
}
#menu ul ul li:last-of-type a {
border-bottom: none;
}
#menu li:hover > a,
#menu ul ul :hover > a {
color: #36bcab;
}
#menu ul ul a:hover {
background: #36bcab;
}
#menu ul li:hover > ul {
display: block;
}
#menu ul li.current_page_item > a,
#menu ul li.current_page_ancestor > a,
#menu ul li.current-menu-item > a {
color: #111;
}
#menu ul:after {
clear: both;
content: ' ';
display: block;
}
You should add a couple of properties to make it work:
#menu-header-menu {
display:table;
margin:0 auto;
padding:0;
}
Nevertheless it's interesting that you say that the shift happened when the number if items in the menu increased, I don't see in the CSS any code that could differentiate the display depending on the number of items. Could you confirm that I understood the situation?

CSS dropdown menu, clear 1st lvl hover

I'm trying to style menu on my website but I'm stuck with coloring and hover effects.
It looks now as below (/user is where cursor was when I took screenshot):
Screenshot
What I need to change is:
when I hover 2nd level item, 1st level becomes "default" (without hover effect)
My CSS for this menu is:
#nav {
text-align: center;
font-size: 1.5em;
font-weight: 700;
letter-spacing: 1px;
}
#nav ul ul {
display: none;
}
#nav ul li:hover > ul {
display: block;
}
#nav ul {
display: inline-table;
list-style: none outside none;
padding: 0 10px;
position: relative;
}
#nav ul:after {
clear: both;
content: "";
display: block;
}
#nav ul li {
float: left;
background: none repeat scroll 0 0 #F5F5F5;
margin-right: 3px;
}
#nav ul li:hover {
background: none repeat scroll 0 0 #E32D40;
}
#nav ul li a {
color: #757575;
display: block;
padding: 10px;
text-decoration: none;
}
#nav ul li a:hover {
color: #FFFFFF;
}
#nav ul ul {
border-radius: 0 0 0 0;
padding: 0;
position: absolute;
top: 100%;
}
#nav ul ul li {
margin-top: 3px;
float: none;
position: relative;
color: #757575;
}
#nav ul ul li a {
color: #757575;
display: block;
padding: 10px;
text-decoration: none;
}
#nav ul ul li a:hover {
}
#nav ul ul ul {
left: 100%;
position: absolute;
top: 0;
}
I'm not sure, if it is possible with only css. As you are displaying the 2nd level with #nav ul li:hover > ul and you are highlighting the 1st with #nav ul li:hover, which are both firing on 2nd level li hover (and there is no parent call in css).
It is quite easy though with jQuery:
$('#nav > ul > li > ul > li').hover(function () {
$(this).parents('li').first().css('background', 'none');
});
Check here: http://jsfiddle.net/balintbako/EruTP/

CSS problems with the Sub menu on my site

I am having some problems with the Sub menu on my site... www.fastfoodforum.co.uk
If you hover over the "forums" item then you will see that the other content of my site jumps, and you will also see small gaps between each sub menu item.
Both of these are very much undesired and I would really appreciate any help in fixing them. I will post the CSS I currently have below, I have been experimenting and trying to fix this for some time so please excuse any messy/dodgy code.
Thanks everyone, really appreciate the help.
#access {
float: left;
margin: 91px 0 0 0px;
width: 550px;
display: block;
}
#access .menu-header, div.menu {
font-size: 13px;
margin-left: 12px;
width: 928px;
}
#access .menu-header ul, div.menu ul {
list-style: none;
margin: 0;
}
#access .menu-header li, div.menu li {
float: left;
margin: 0;
padding: 9px 17px 0 0;
position: relative;
}
#access a {
color: #FFFFFF;
font-size: 13px;
font-weight: bold;
margin: 0;
text-decoration: none;
}
#access ul ul {
box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);
display: none;
position: absolute;
top: 30px;
left: 0;
float: left;
width: 80px;
z-index: 99999;
padding-top: 0px;
}
#access ul ul li {
min-width: 80px;
padding-top: 0px;
padding-bottom: 0px;
}
#access ul ul ul {
left: 100%;
top: 0;
padding-top: 0px;
}
#access ul ul a {
background: #333;
line-height: 1em;
padding: 8px;
width: 80px;
height: auto;
display: inline-table;
}
#access li:hover > a, #access ul ul :hover > a {
color: #fff;
}
#access ul li:hover > ul {
display: inline-table;
position: relative;
}
#access ul li.current_page_item > a, #access ul li.current-menu-ancestor > a, #access ul li.current-menu-item > a, #access ul li.current-menu-parent > a {
color: #fff;
}
* html #access ul li.current_page_item a, * html #access ul li.current-menu-ancestor a, * html #access ul li.current-menu-item a, * html #access ul li.current-menu-parent a, * html #access ul li a:hover {
color: #fff;
}
Try to change this:
#access ul li:hover > ul {
display: inline-table;
position: relative;
}
to this:
#access ul li:hover > ul {
display: block;
}

CSS menu and sub menu issues + browser px issues for webkit [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Here where my css menu is: My css menu
Notice if you hover over "about us" like below you see the "our clergy" sub menu already out. I don't want that I want it when you hover over "our clergy" for it to show.
This screenshot above is from firefox, while webkit browsers show a 1-2px difference as seen below and I can't figure out why? It sometimes effects how the menu works too.
Here is my css for the menu (I'm using wordpress so that means there is no html):
Feel free to help me out and if you want to clean up the css you can too!
#navbar {
height: 40px;
padding-left: 10px;
margin-left:-10px;
margin-top: -29px;
margin-bottom:0;
background: #F4DE9F;
width:930px;
/*backgroundborder-top: 2px solid #F4DE9F;
border-bottom: 2px solid #F4DE9F;*/
}
#navbar li {
float: left;
list-style: none;
margin-bottom: 30px;
margin-left:-20px;
}
#navbar li a {
font-family: "MuseoSans_500";
color: #3C290B;
font-weight: 500;
text-transform: uppercase;
}
#navbar li:hover {
background:rgba(255, 241, 194, 100); /*#FFF1C2;*/
color: #645548;
text-decoration: none;
}
#navbar li a:hover {
background:rgba(255, 241, 194, 100); /*#FFF1C2;*/
color: #645548;
text-decoration: none;
}
#navbar .parent > a, #navbar .parent > a:hover {
background: #F4DE9F;
background-position: right;
background-repeat: no-repeat;
}
#navbar ul, #navbar ul li {
display: inline;
list-style: none;
margin: 0;
padding: 0;
}
#navbar ul li a {
display: inline-block;
padding: 11px 16.2px 8px;
text-decoration: none;
}
/*
#navbar ul li a:hover {
}
#navbar ul #first a:hover {
}*/
#navbar ul li {
position: relative;
}
#navbar li ul {
display: none;
left: 11px;
position: absolute;
top: 51px;
}
#navbar li ul a {
background: #F4DE9F;
}
#navbar ul ul ul li {
}
#navbar ul li:hover ul {
display: inline-block;
}
#navbar ul li:hover ul, #navbar ul ul li:hover ul, #navbar ul ul ul li:hover ul {
display: block;
margin: -11px 0 0 -11px;
}
/*#navbar ul li:hover ul li a, #navbar ul ul li:hover ul li a, #navbar ul ul ul li:hover ul li a {
display: block;
}*/
#navbar ul li:hover ul ul, #navbar ul ul li:hover ul ul {
margin-top: -50px;
margin-left:129px;
}
#navbar ul li:hover ul li a {
padding: 10px 14px 8px;
width: 112px;
}
#navbar ul li:hover ul ul li a {
padding: 10px 14px 8px;
width: 112px;
}
/*#navbar ul ul ul li:hover ul li a {
padding: 0 16px 0 24px;
width: 140px;
}*/
#navbar .children li a:hover {
color: #000;
}
When you end up with a stylesheet that feels very bloated with several rules and a lot of specificity, such as #navbar ul ul ul li:hover ul it is usually good to take a step back see if you can simplify the rules a bit.
Since you are using Wordpress it comes with a lot of handy classes that makes the job easier. In this case .menu-item and .sub-menu.
Replacing the menu-css with the following styles solves the problems you mentioned in your question, tried in Chrome 23, Safari 6 and Firefox 16.
Example here: http://jsfiddle.net/5qEwH/
.menu-item {
display: inline-block;
position: relative;
font-family: "MuseoSans_500";
font-weight: 500;
text-transform: uppercase;
background: #F4DE9F;
}
.menu-item:hover {
background: #FFF1C2;
}
.menu-item a {
display: inline-block;
height: 20px;
padding: 10px;
text-decoration: none;
color: #645548;
}
/* Hide submenus by default */
.sub-menu {
display: none;
position: absolute;
width: 150px;
top: 40px;
}
.sub-menu .menu-item {
width: 100%;
}
/* The second level sub-menu should be moved to the right */
.sub-menu .menu-item > .sub-menu {
top: 0;
left: 150px;
}
/* Show submenus on hover */
.menu-item:hover > .sub-menu {
display: block;
}
Its a great CSS practice to normalize your styles first so that all the browsers get the same styles for some basic HTML elements.
I add this at the start of a Stylesheet
* { margin: 0px; padding: 0px; border: 0px; text-decoration: none }
There is also a comprehensive stylesheet file for normalization that covers all the browsers and even html5 as well. try to add this before your style.css file.
Here is the link: http://necolas.github.com/normalize.css/
For the hover issue, try this css change
Replace
#navbar ul li:hover ul {
display: inline-block;
}
#navbar ul li:hover ul, #navbar ul ul li:hover ul, #navbar ul ul ul li:hover ul {
display: block;
margin: -11px 0 0 -11px;
}
With
#navbar ul li:hover > ul {
display: inline-block;
}
#navbar ul li:hover > ul, #navbar ul ul li:hover > ul, #navbar ul ul ul li:hover > ul {
display: block;
margin: -11px 0 0 -11px;
}
Hope it helps :)

Menu Style in Wordpress

I posted this question over wordpress.stackexchange.com but they closed it and pointed me to post here.
I am not sure whether it is the right place for such question but I did not find any CSS related section here.
Please see the below image.
Currently my menus are similar to A but I want it to be like B. I also want to change the color of the separator from Black to Green in sub menu. I want this effect only on the sub menu whether sub menu page is selected or not. How can I do that?
Here is the selected code from my style.css:
.menu {
font: normal 13px Arial, sans-serif;
background: url() repeat-x 0 -80px;
width: 100%;
height: 35px;
position: relative; /* Required for positioning of sub-menus */
}
.menu li ul {
display: none; /* Required to hide menu when inactive */
position: absolute; /* Position the menu below and to the far left */
top: 50px;
left: 0;
}
/* This is the rule that displays sub-menus when a parent link is clicked */
.menu li.current-menu-parent ul, .menu li.current-menu-item ul {
display: block;
}
.menu li {
float: left;
margin: 0;
padding: 0;
font-weight: bold;
border-right:#3c3c3c solid 1px;
}
.menu li a {
float: left;
display: block;
color: #fff;
background: url() repeat-x 100% 0;
padding: 12px 25px;
text-decoration: none;
}
.menu li a:hover {
background-position: 100% -160px;
color: #fff;
}
/* Styling for current parent item */
.menu li.current-menu-item a, .menu li.current-menu-parent a{
background: url() repeat-x scroll left bottom #83C839;
}
/* Styling for sub-menus */
.menu li ul {
width: 805px;
background: url() repeat-x 0 -120px;
border: 1px solid #83C839;
border-style: none none solid;
border-width: 3px;
}
.menu li ul li {
padding: 6px 0;
}
.menu li.current-menu-item ul li a, .menu li.current-menu-parent ul li a {
background: url() repeat-y right center;
color: #666666;
padding: 12px 25px;
margin: -6px 0;
}
.menu li ul li a:hover {
color: #000;
}
/* Styling for current page sub-menu links */
.menu li.current-menu-parent ul li.current-menu-item a, .menu li.current-menu-parent ul li.current-menu-item a:hover {
background: url("") repeat-x scroll left bottom #83C839;
color: #FFFFFF;
}
I am using this code in Wordpress Theme. My code is based upon WordPress Tutorial – Current & Parent Menu Items In Custom Menus code, I modified it according to my need.

Resources