Having some problems getting the drop down menu position or mainly the background of it in place with the links from drop down menu, can't figure out what could be the problem... Here's the CSS code (menu li ul) image on how it looks -> http://i.imgur.com/9VjpW.jpg or jsFiddle http://jsfiddle.net/F5wCG/3/
.menu ul{
background-color: transparent;
height: 25px;
list-style: none;
margin: 0;
padding: 0;
position: relative;
clear: left;
float: right;
text-align: center;
right: 50%;
}
.menu li{
float: left;
padding: 0px;
position: relative;
left: 50%;
margin: 0px;
list-style: none;
}
.menu li a{ /* Where main link names are etc */
background: #333 url("images/seperator.gif") bottom right no-repeat;
color: #CCC;
display: block;
font-weight: normal;
line-height: 35px;
margin: 0px;
padding: 0px 25px;
text-align: center;
text-decoration: none;
}
.menu li a:hover, .menu ul li:hover a{
background-color: #2580A2;
background-image: url('images/hover.gif');
background-position: bottom center;
background-repeat: no-repeat;
color:#FFFFFF;
text-decoration:none;
}
.menu li ul{ /* Drop down menu */
background-color: #333;
display: none;
height: auto;
border: 0px;
position: absolute;
width: 225px;
z-index: 200;
padding: 0px;
margin: 0px;
border: 0px;
}
.menu li:hover ul{
display: block;
}
.menu li li {
background: url('images/sub_sep.gif') bottom left no-repeat;
display: block;
float: none;
width: 220px;
}
.menu li:hover li a{
background: none;
}
.menu li ul a{
display: block;
height: 35px;
font-size: 12px;
font-style: normal;
margin: 0px;
padding: 0px 10px 0px 15px;
text-align: left;
}
.menu li ul a:hover, .menu li ul li:hover a{
background: #2580A2;
background-image: url(images/hover_sub.gif);
background-position: center left;
background-repeat: no-repeat;
border: 0px;
color: #FFF;
text-decoration: none;
}
.menu p{
clear: left;
}
http://jsfiddle.net/F5wCG/4/
Basically remove
.menu li { left: 50% }
and add
.menu li a {left:0; }
Related
How me doing dropdown menu for pages and child pages on wordpress 4.0, but wp_page_menu not working, wp_list_pages('title_li=') ?> show menu but not show child pages. please help?
Try this:
ul.menu { list-style: none outside none; padding: 0; margin: 0 10px; float: left; font-size: 13px;}
ul.menu li { float: left; margin: 0; padding: 0 15px 0 0; position: relative; }
ul.menu li a { padding: 9px 5px; color: rgb(255, 255, 255); display: block; text-decoration: none; float: left; display: block;}
ul.menu li:hover { background: #A6CB1B; }
.current-cat { background: #8BBF47; }
ul.menu li span { width: 11px; height: 10px; float: left; background: url('/*url of your background or write color anme*/') -561px -78px no-repeat; margin: 11px 0 0 0;}
ul.menu li ul.children {z-index:99; list-style: none outside none; position: absolute; left: 0; top: 31px; background: none repeat scroll 0% 0% rgb(51, 51, 51); margin: 0; padding: 0; display: none; float: left; width: 170px; border-bottom: 1px solid #F8C92D;}
ul.menu li ul.children li { margin: 0; padding: 0; clear: both; width: 170px; border-top: 1px solid #F8C92D;}
html ul.menu li ul.children li a { float: left; width: 145px; background: url('images/narga-sprites.png') -578px -162px no-repeat #A6CB1B; padding-left: 20px; }
html ul.menu li ul.children li a:hover { background: url('/*url of your background or write color anme same as above*/') -578px -162px no-repeat #7BAF36; }
NOTE: This code is untested.Make sure to do necessary changes as per your needs.
I'm trying to make my website's menu elements next to each other with the display: inline-block. I've tried it in different parts of my CSS menu, like at the 'cssmenu li' etc, but it doesn't work. Somebody knows how to help me?
The CSS:
#cssmenu {
border: none;
border: 0px;
margin: -17px;
padding: 0px 0px 0;
font-family: "Times New Roman", Verdana, Helvetica, sans-serif;
font-size: 19px;
font-weight: none;
float: left;
width: 600;
margin-left: 300px;
z-index: 999;
position: fixed;
}
#cssmenu ul {
background: #fff;
height: 30px;
list-style: none;
margin: 0;
padding: 0;
}
#cssmenu li {
display: block;
float: left;
padding: 0px;
}
#cssmenu li a {
background: #fff url('seperator.png') bottom right no-repeat;
font-weight: normal;
line-height: 35px;
margin: 0px;
padding: 0px 25px;
text-align: center;
text-decoration: none;
}
#cssmenu > ul > li > a {
color: #000;
}
#cssmenu ul ul a {
color: #000;
}
#cssmenu li > a:hover,
#cssmenu ul li:hover > a {
background: #fff url('hover.png') bottom center no-repeat;
color: #ddd;
text-decoration: none;
}
#cssmenu li ul {
display: none;
background: #fff;
height: auto;
padding: 0px;
margin: 0px;
border: 0px;
position: absolute;
width: 225px;
z-index: 200;
/*top:1em;*/
/*left:0px;*/
}
#cssmenu li:hover ul {
display: block;
}
#cssmenu li li {
background: url('sub_sep.png') bottom left no-repeat;
float: auto;
margin: 0px;
display: block;
padding: 0px;
width: 225px;
background: #hhh url('hover_sub.png') center left no-repeat;
border: 0px;
color: #000;
}
#cssmenu li:hover li a {
background: none;
color: #000;
font: "Times New Roman", Verdana, Helvetica, sans-serif;
font-size: 15px;
text-align: center;
}
#cssmenu li ul a {
display: block;
height: 35px;
font-size: 12px;
font-style: normal;
margin: 0px;
padding: 0px 10px 0px 15px;
text-align: left;
}
#cssmenu li ul a:hover,
#cssmenu li ul li:hover > a {
background: #fff url('hover_sub.png') center left no-repeat;
border: 0px;
color: #000;
text-decoration: none;
}
#cssmenu p {
clear: left;
}
You can make it with #cssmenu li {display: inline block;} and #cssmenu li a {padding: 0 16px;} but your html is wrong. Check your ul's and li's again. You need:
<div id="cssmenu">
<ul>
<li class="has-sub">
<a></a>
...
</li>
<li class="has-sub">
<a></a>
...
</li>
<li class="has-sub">
<a></a>
...
</li>
</ul>
</div>
I created a css drop down menu and i am finishing it up with a border. When i added the left and bottom border everything was fine. Once i added the right border it put a gap between the right border and the drop down menu. Is there anyway to fix this?
Here is a photo http://sphotos-b.ak.fbcdn.net/hphotos-ak-ash3/563034_641717089180441_1749213926_n.jpg
The HTML I Used:
<nav id="main_nav" class="fluid">
<ul>
<li>Home</li>
<li>Show Services
<ul>
<li>Audio</li>
<li>Lighting</li>
<li>Power</li>
<li>Special Effects</li>
<li>Staging/Trussing</li>
<li>Video</li>
</ul>
</li>
<li>Systems Integration
<ul>
<li>Corporate and Commercial</li>
<li>Digital Signage</li>
<li>Entertainment</li>
<li>IP Based Systems</li>
</ul>
</li>
<li>Portfolio
<ul>
<li>Concrets</li>
<li>Installations</li>
<li>Parties</li>
<li>Product Launch</li>
<li>Trade Shows</li>
</ul>
</li>
<li>Our Company</li>
</ul>
</nav>
The CSS I Used:
#main_nav {
}
#main_nav ul {
list-style-type: none;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
width: 100%;
position: relative;
float: left;
}
#main_nav ul li {
float: left;
position: relative;
width: 20%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
background-color: #4d4d4d;
}
#main_nav ul li a {
width: 100%;
float: left;
text-align: center;
text-transform: uppercase;
color: #FFFFFF;
text-decoration: none;
padding-top: 0%;
font-style: normal;
font-weight: 400;
font-family: allerta;
font-size: 1em;
display: block;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
border-left: 0.1em solid #999999;
border-bottom: 0.1em solid #999999;
border-right: 0.1em solid #999999;
}
#main_nav a:hover, #main_nav a:active, #main_nav a:focus, #main_nav a.thispage {
background-color: #666666;
color: #0099FF;
width: 100%;
}
#main_nav ul li ul {
visibility: hidden;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
float: left;
list-style-type: none;
position: absolute;
margin-top: 100%;
padding-top: 0%;
width: 100%;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
#main_nav ul li ul li {
position: relative;
float: left;
width: 100%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
background-color: #4d4d4d;
}
#main_nav ul li ul li a {
width: 100%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
margin-top: 0%;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0%;
float: left;
font-style: normal;
font-weight: 400;
font-family: allerta;
font-size: 0.9em;
text-align: center;
text-decoration: none;
display: block;
color: #FFFFFF;
text-transform: uppercase;
}
#main_nav ul li:hover ul, #main_nav ul li:active ul, #main_nav ul li:focus ul, #main_nav ul li.thispage ul {
visibility: visible;
width: 100%;
}
I took a look at your code and have made some changes. Also took the liberty of creating a JS Fiddle example for you. I haven't changed any HTML, only the CSS.
See JS Fiddle here
html {
font: 100%/1.5 Arial, Helvetica, sans-serif;
}
html, body {
margin: 0;
}
/* Common (Shared) Properties */
#main_nav, ul, li, a {
display: block;
margin: 0;
padding: 0;
}
#main_nav ul {
list-style: none;
width: 100%;
position: relative;
float: left;
}
#main_nav li {
float: left;
position: relative;
width: 20%;
background: #4d4d4d;
}
#main_nav a {
float: none;
text-align: center;
text-transform: uppercase;
color: #FFF;
text-decoration: none;
font-size: 1em;
border: 1px solid #999;
border-top: none;
}
#main_nav a:hover,
#main_nav a:active,
#main_nav a:focus,
#main_nav a.thispage {
background: #666;
color: #FFF;
}
/* Controls Dropdown */
#main_nav ul li ul {
visibility: hidden;
position: absolute;
top: auto; /* Updated position to 'auto' and removed margin-top: 100% */
left: 0;
}
#main_nav ul ul li {
float: none;
width: 100%;
}
#main_nav ul li:hover ul,
#main_nav ul li:active ul,
#main_nav ul li:focus ul,
#main_nav ul li.thispage ul {
visibility: visible;
display: block;
}
I rewrote CSS which hopefully will be helpful to learn from as it is much simpler to understand as well as it fixes your problem.
Problem was that the sub menu items were with 100% width + 1px border on each side which is over 100% so it was overflowing.
Here is the link to JS Fiddle example with fix: http://jsfiddle.net/MartinTale/69gDQ/3/
Here is the new css:
#main_nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#main_nav ul {
width: 100%;
}
#main_nav li {
background-color: #4d4d4d;
margin: 0;
padding: 0;
text-align: center;
width: 100%;
}
#main_nav > ul > li {
float: left;
width: 20%;
}
#main_nav ul ul {
display: none;
}
#main_nav ul li:hover ul {
display: inline-block;
}
#main_nav a {
text-align: center;
text-decoration: none;
color: #FFF;
text-transform: uppercase;
display: inline-block;
width: 100%;
border-left: 1px solid #999999;
border-bottom: 1px solid #999999;
border-right: 1px solid #999999;
}
#main_nav ul li ul a {
border-left: 0;
border-right: 0;
}
#main_nav a:hover,
#main_nav a:active,
#main_nav a:focus,
#main_nav a.thispage {
background: #666;
color: #09F;
}
I've created a drop down menu using css where the drop down appears as a horizontal row instead of a vertical list. My only problem is that the drop down menu does not line up with the rest of menu. I want it to be flush with the left side of the navigation bar.
The page is up at this address: http://concept82.com/CBHweb/index2.html
The code for my drop down menu is:
#navholder{
background-color: #594361;
margin: 0 auto;
width: 868px;
height: 25px;
font-family: P22, Helvetica, Arial, sans-serif;
}
#nav {
margin: 1px;
padding: 0px;
}
#nav li {
list-style: none;
float: left;
}
#nav li a {
display: block;
color: #FFFFFF;
font-size: 14px;
text-align: center;
margin-top: 5px;
text-transform: uppercase;
text-decoration: none;
letter-spacing: 3px;
width: 140px;
}
#nav li a:hover {
color: #201E30;
}
#nav li ul {
display: none;
}
#nav li ul a{
width: auto;
font-size: 11px;
}
#nav li:hover ul, #nav li.hover ul {
position: absolute;
left: 0;
display: inline;
padding-top: 5px;
}
#nav li:hover li, #nav li.hover li {
float: left;
display: block;
text-decoration: none;
color: #594361;
font-size: 11px;
border-right: 1px solid #594361;
padding: 0px 15px 0px 15px;
margin-top: 3px;
margin-bottom: 3px;
white-space: nowrap;
}
#nav li.first, #nav li.hover li.first {
float: left;
display: block;
text-decoration: none;
color: #594361;
font-size: 11px;
border-left: 1px solid #594361;
padding: 2px 15px 2px 5px;
margin-top: 3px;
white-space: nowrap;
}
#nav li:hover li a, #nav li.hover li a {
color: #201E30;
background-color: #FFFFFF;
}
#nav li li a:hover {
color: #201E30;
}
Thanks ahead of time!
You should change position of #navholder as relative.
#navholder{
position: relative;
background-color: #594361;
margin: 0 auto;
width: 868px;
height: 25px;
font-family: P22, Helvetica, Arial, sans-serif;
}
When you define the ul when hovering on the list you specify left as 0 px, aligining it to the left of the page, change it to your margin width then it will be in the right place
#nav li:hover ul, #nav li.hover ul {
position: absolute;
left: 0;
display: inline;
padding-top: 5px;
}
This is the CSS for the dropdown menu I create, the problem is that the menu disappears as soon as I hover the children items.
It gets fixed If I set Height:30px and line-height: 30px but I do not want to adjust height. I want it to auto adjust. I can't get it to work in IE7. This is my CSS
#menu {
display: block;
width: 1000px;
height: 30px;
background: url(../images/modern/menu.png) no-repeat;
margin: 10px 0 0 0;
position: relative;
z-index: 10;
}
#menu ul {
float: left;
margin: 0 0 0 5px;
display: inline;
width: 795px;
}
#menu ul li {
position: relative;
float: left;
display: block;
position: relative;
}
#menu ul li a {
float: left;
display: block;
color: #fff;
font-weight: bold;
padding: 9px 10px 9px 10px;
background: url(../images/modern/menu_l.png) no-repeat right;
}
/* sub menu style */
#menu ul ul {
padding:0;margin:0;border:none;
float: none;
display: none;
position: absolute;
z-index: 10;
width: 190px;
top: 29px;
left: 0;
}
#menu ul ul ul {
top: 0;
left: 190px;
}
#menu ul ul li {
float: none;
display: block;
position: relative;
}
#menu ul ul li a {
padding:0;margin:0;border:none;
float: none;
display: block;
font-weight: bold;
position: static;
background: none;
color: #fff;
padding: 6px 10px 6px 10px;
background: #333;
border-bottom: 1px solid #444;
}
This fixes it but I really do not want to set height for child item:
#menu ul ul li a {
padding:0;margin:0;border:none;
float: none;
display: block;
font-weight: bold;
position: static;
background: none;
color: #fff;
padding: 6px 10px 6px 10px;
background: #333;
border-bottom: 1px solid #444;
height: 30px;
line-height: 30px;
}
Try zoom:1; to the thing you applied height:30px; to.