working on a simple nav bar. so far its working perfectly for me minus one minor detail. when it drops down i want the middle sections to remain a rectangle and the bottom section to always be curvy on the bottom. right now I have it so the bottom section is curvy, though when I hover over it the regular rectangle shows back up. I tried to fix it myself, but all I could get to work was it would change all sections to curvy
here is a jsFiddle of what I am working on: http://jsfiddle.net/7mjEC/
and here is the css:
#charset "utf-8";
#topMenu {
padding: 0px;
width: 760px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
position: relative;
top: 80px;
}
#topMenu ul {
margin: 0px;
padding: 0px;
}
#topMenu ul li {
background-color: #666;
float: left;
border: 1px solid #999999;
position: relative;
list-style-type: none;
}
#topMenu ul li a {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 30px;
color: #FFF;
text-decoration: none;
text-align: center;
display: block;
height: 30px;
width: 150px;
}
#topMenu ul ul {
position: absolute;
visibility: hidden;
top: 31px;
}
#topMenu ul li ul li a:hover {
background-color: #39F;
}
#topMenu ul li:hover ul {
visibility: visible;
}
#topMenu ul li:hover {
background-color: #919191;
}
#topMenu .topleftmenuitem {
border-radius: 20px 0 0 20px;
}
#topMenu .toprightmenuitem {
border-radius: 0 20px 20px 0;
}
#topMenu .topleftmenuitem:hover {
border-radius: 20px 0 0 0;
}
and #topMenu .toprightmenuitem:hover {
border-radius: 0 20px 0 0;
}
#topMenu ul ul li:last-child {
border-radius: 0 0 20px 20px;
}
see when you hover over the last child it turns from curved to rectangle, I just want to keep it always curved.
You need to use :last-of-type or :last-child pseudo
#topMenu > ul > li > ul > li:last-of-type a:hover {
border-radius: 0 0 20px 20px;
background: #f00; /* You can remove this, its just for a demo */
}
Demo
The above selector means, select direct child ul to element having an id of #topMenu, than select direct li to that ul, moving further applies the same and at the end, we select the last li child which is nested under level 2 ul and we apply the styles on a:hover
I have updated your fiddle. You DO NOT need to break all of the ul's up like this. Please see my Fiddle for much simpler code:
http://jsfiddle.net/7mjEC/2/
The only css change you really need is to add ONE selector in:
ul ul li:last-child,
ul ul li:last-child a {
border-radius: 0 0 20px 20px;
}
Related
there is a double red line on hover state on my active link (another red line appears on dropdown menu. How to fix this. Also when i moving on dpopdown menu active state dissapears.
JSFIDDLE
Thank you.
Have a nice day.
[1]: http://jsfiddle.net/uj5k5ecq/
Adding a new class .jqueryslidemenu ul li a.active:hover and giving it a border-bottom:0; should do it, but there's something that I'm trying to figuring out is why the drop down is not filling that 5px removed from the border-bottom ... until now I have this:
.jqueryslidemenu ul li a.active:hover {
border-bottom:0;
}
======== Update ==========
I figured it out, it's somehere in your jquery code (probably in your file jqueryslidemenu.js) that has a static position for your dropdown of top:56px; by giving a new top value for .jqueryslidemenu ul li ul through your css like this it will fix this issue
.jqueryslidemenu ul li ul {
top: 51px !important;
}
Online demo here
but perhaps you should find that value and change it there tho, where this top:56px; is being created
One option is to remove the on hover underline by adding this to your CSS:
#nav a:hover{text-decoration:none;}
Another option is to remove the red border when you hover over a dropdown by removing border-top: 5px solid #eb2629;. Example below:
.jqueryslidemenu ul li ul {
position: absolute;
left: 0;
margin-left: -1px;
border-top: 5px solid #eb2629; /** REMOVE THIS LINE **/
display: block;
visibility: hidden;
background: #000;
z-index: 99999;
}
A third option is to remove the active red border when you hover over the link itself:
.jqueryslidemenu ul li a.active {
border-bottom: 5px solid #eb2629; /** REMOVE THIS LINE **/
color: #eb2629;
}
Just add
#nav a {
text-decoration: none;
}
View DEMO
Your question is not very clear but I think you might mean something like this?
http://jsfiddle.net/uj5k5ecq/3/
#nav {
float: right;
margin-top: 70px;
position: relative;
}
.jqueryslidemenu ul {
z-index:9999999;
}
.jqueryslidemenu ul li {
position: relative;
float: left;
list-style:none;
}
.jqueryslidemenu ul li a {
font-weight: normal;
text-transform: uppercase;
font-size: 13px;
margin-top: 18px;
padding: 0px 20px 15px;
display: block;
text-decoration:none;
color:#000;
}
.jqueryslidemenu ul li a:hover {
border-bottom: 5px solid #eb2629;
color: #eb2629;
}
.jqueryslidemenu ul li a.active {
}
.jqueryslidemenu ul li ul {
position: absolute;
left: 0;
margin-left: -1px;
border-top: 5px solid #eb2629;
display: block;
visibility: hidden;
background: #000;
z-index: 99999;
}
/*Sub level menu list items (undo style from Top level List Items)*/
.jqueryslidemenu ul li ul li {
float: none;
font-size:12px;
width: 160px;
text-transform: none;
background-color: #000;
}
.jqueryslidemenu ul li ul li a {
margin: 0px;
color:#fff;
padding: 10px 20px 10px;
border-bottom: none;
text-transform: none;
}
.jqueryslidemenu ul li ul li a:hover {
background:#232323;
color: #FFF;
border-bottom: none;
text-transform: none;
}
I know this question has been asked quite a few times, but I'm working on a Wordpress theme and I have the submenus styled exactly how I want them. However, they disappear upon hover. I have set all of my margin-tops to zero as stated on Stack previously but they still don't work properly.
My CSS for this top navigation is the following:
.top-nav {
background-color: #444;
min-height: 40px;
}
.top-nav ul {
margin-bottom: 0;
}
.top-nav li {
margin: 0 20px 0 0;
padding: 0;
float: left;
display: inline-block;
position: relative;
}
.top-nav li a {
color: #aaa;
font-size: 12px;
line-height: 40px;
}
.top-nav li a:hover, .top-nav li.current-menu-item a {
color: #fff;
background-color: #444;
}
.top-nav ul li ul.sub-menu {
display: none;
margin-top:0px;}
.top-nav ul li:hover > .sub-menu {
display: block;
position: absolute;
height: 0px;
margin-top:-5px;
overflow: visible;
margin-left:0px;}
.top-nav li.menu-item ul li {
display: block;
position:relative;
width: 100%;
float: left;
margin:0px;
padding:5px 0 5px 10px;
background-color:#444!important;
border-bottom: 1px solid #faf3bf;}
.top-nav ul li.menu-item ul li a {
width: inherit;
padding: 0;}
Any help would be greatly appreciated.
Had to add:
z-index: 1; to .top-nav li.menu-item ul li
The H3 of the title was covering the dropdown.
I recently built my first website (with much trial and error) and was quite pleased until I noticed that when you scroll down the page a little it creates a gap in the navigation so you can't click on the dropdowns. I'm going crazy trying to fix it. Can anyone please help? The site is at: http://lamplighters.org/education/smw.html
it appears to be an position issue that is set witht the element on the css. It would help to see your html and css code.
I can tell you that it has to do with the fact you used position: fixed. You have a series of other problems with your CSS as well.
I inspeceted the page and found a lot of things that didn't come together well for the navigation. Good housekeeping is not in order.
#nav, #nav ul {/*By doing this you are setting these attributes to both the nav div and the nav ul*/
padding: 0;
margin: 0;
list-style: none;
line-height: 1;
text-align: center;
}
#nav, #nav ul {/*By doing this you are setting these attributes to both the nav div and the nav ul. This is redundant and should be consolodated into a single #nav, #nav ul, if you are going to use these assigned attributes. */
padding: 0;
margin: 0;
list-style: none;
display: inline-block;
}
ul {/*By doing this you are only targeting any ul on the page*/
list-style: none outside;
}
ul, ol {/*By doing this are targeting both ordered lists and unordered lists to have these attributes*/
margin-bottom: 20px;
}
ol, ul {/*By doing this are targeting both ordered lists and unordered lists to have these attributes*/
list-style: none;
}
#nav li {
float: left;
width: 137px;
text-transform: capitalize;
display: inherit;
position: relative;
}
li {
line-height: 18px;
margin-bottom: 12px;
}
You may want to wipe your nav css clean and start from scratch.
I pulled a css file and put it below. hope this helps. Good luck with your sytle sheets in the future.
#menu{
width: 960px;
margin: 50px 0 0 0;
padding: 10px 0 0 0;
list-style: none;
}
#menu li{
float: left;
padding: 0 0 10px 0;
position: relative;
}
#menu a{
float: left;
height: 25px;
padding: 0 60px;
text-decoration: none;
}
/*Text Color for the anchors*/
#menu li:hover > a{
color: #FFFFFF;
}
*html #menu li a:hover{ /* IE6 */
color: #FFFFFF;
}
#menu li:hover > ul{
display: block;
}
/* Sub-menu */
#menu ul{
list-style: none;
margin: 0 35px;
padding: 0 15px;
display: none;
position: absolute;
top: 35px;
left: 0;
z-index: 99999;
}
#menu ul li{
float: none;
margin: 0;
padding: 0;
display: block;
}
#menu ul a{
padding: 10px;
height: auto;
line-height: 1;
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
*html #menu ul a{ /* IE6 */
height: 10px;
width: 150px;
}
*:first-child+html #menu ul a{ /* IE7 */
height: 10px;
width: 150px;
}
#menu ul a:hover{
/*add a background position*/
background-position: left top;
}
#menu ul li:first-child a{
}
#menu ul li:first-child a:after{
content: '';
position: absolute;
left: 30px;
top: -8px;
width: 0;
height: 0;
}
#menu ul li:first-child a:hover:after{
/*add color scheme*/
}
#menu ul li:last-child a{
}
/* Clear floated elements */
#menu:after{
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html #menu { zoom: 1; } /* IE6 */
*:first-child+html #menu { zoom: 1; } /* IE7 */
I am having a simple problem with my CSS dropdown menu, I want to make it so the dropdowns are equal length to the button above them. See example below, I just want to stretch the block to the length of the above block.
New user, can't upload image
If you use my jsFiddle link you can see my code, and edit it live. I'll post the code anyway just in case.. Note I am only posting the CSS stylesheet in here as the HTML is not part of the problem.
/* Dropdown Menu */
#nav {
float: right;
width: 600px;
height: 90px;
margin: 0 auto;
padding-top: 65px;
}
#nav ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
float: right;
}
#nav ul li {
display: block;
position: relative;
float: left;
}
#nav li ul { display: none; }
#nav ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #3636FE;
margin-left: 1px;
white-space: nowrap;
}
#nav ul li a:hover { background: #3636FE; }
#nav li:hover ul {
display: block;
position: absolute;
}
#nav li:hover li {
float: none;
font-size: 11px;
}
#nav li:hover a { background: #3636FE; }
#nav li:hover li a:hover { background: #6868FE; }
Fixed. (at least for Chrome+Firefox+IE9)
http://jsfiddle.net/QZWj3/4/
You had to add width: 100% to #nav li:hover ul and to #nav li:hover li
I seem to be running into a strange issue with IE7.
If you visit the following URL, http://tinyurl.com/3qrbhn4, and hover over the main navigation at the top, right above the header image in Chrome, Firefox, and IE8, the sub nav that displays once you hover over a nav element (for example, hover over Meetings) appears to line up correctly with the parent LI. However, if you try hovering over the main nav in IE7, the subnav appears one pixel off.
If you inspect the nested UL, which is #mainNav ul ul, you'll notice that it's being positioned absolutely inside of the parent UL with a left vale of 0.
If I give it a left value of left:1px, however, it lines up correctly in IE7, but breaks in Chrome/FF/IE8.
I'm not sure why this is happening, and I currently have the parent UL (#mainNav ul) positioned relatively, so I'm not sure why there would be a difference in how IE7 displays the subnav UL. I know I can "fix" this with an IE hack and just force IE7 to display the subnav ul with a left value of 1px, but I'd like to avoid that route if possible.
Can anyone help? Please let me know if I've provided enough information! I'm listing the CSS for the nav elements in question:
/* NAVIGATION *********************************************************************************************** */
#mainNav { position: relative; width: 951px; margin: 0 auto; padding: 15px 0; z-index: 3; }
#mainNav ul { line-height: 100%; height: 35px; margin: 0; padding: 0; font-size: 20px; width: 951px; }
#mainNav ul li { line-height: 100%; list-style: none; float: left; text-transform: uppercase; height: 100%; position: relative; display: block; }
#mainNav ul li a { line-height: 0; height: 22px; border: 1px solid transparent; text-decoration: none; padding: 7px 15px 5px; position:relative; display: block; }
#mainNav ul li a:hover { }
#mainNav ul li.hover a { }
#mainNav ul li a.current { }
#mainNav ul li.lastItem { }
#mainNav ul ul { display: none; z-index:2; position: absolute; top: 35px; left: 0px; padding: 5px 0 10px; width: 200px; height: auto; -moz-box-shadow: 3px 3px 3px #444; -moz-box-shadow: 3px 3px 3px rgba(0,0,0,0.5); -webkit-box-shadow: 3px 3px 3px rgba(0,0,0,0.5); }
#mainNav ul li.current ul { left: 1px; }
#mainNav ul li.hover ul li { background-position: 10px 8px; background-repeat: no-repeat; }
#mainNav ul li.hover ul li.hover { background-color: #baceda; background-position: 10px -20px; }
#mainNav ul li ul li { float: none; }
#mainNav ul li ul li a { background: none; line-height: 1; font-size: 15px; padding: 3px 30px 0; }
#mainNav ul li ul li.hover a { }
#mainNav ul li ul li a.current { }
Try changing #mainNav ul ul from left:1px to left:auto.