Once we mouse-over on "currency", we can see drop down as below:
what I need is once we mouse-over on particular currency[ row], it should show different background color like below.
<style type="text/css">
.menuBackground {
background: brown;
text-align: center;
}
.dropDownMenu a {
color: #FFF;
}
.dropDownMenu,
.dropDownMenu ul {
list-style: none;
margin: 0;
padding: 0;
}
.dropDownMenu li {
position: relative;
}
.dropDownMenu a {
padding: 10px 20px;
display: block;
text-decoration: none;
}
.dropDownMenu a:first-child {
color: #000;
}
.dropDownMenu > li {
display: inline-block;
vertical-align: top;
margin-left: -4px; /* solve the 4 pixels spacing between list-items */
}
.dropDownMenu > li:first-child {
margin-left: 0;
}
.dropDownMenu ul {
box-shadow: 2px 2px 15px 0 rgba(0,0,0, 0.5);
}
.dropDownMenu > li > ul {
text-align: left;
display: none;
background: green;
position: absolute;
top: 100%;
left: 0;
width: 240px;
z-index: 999999;
}
</style>
How?
its good to add colors on anchor tag not to li because you have already styled color on anchor, So just add hover css on anchor you will see what you want.
.dropDownMenu li a:hover {
background: #fff; /*Your color*/
color: #000; /*Your color*/
}
When you want to do is give style on ul li then consider as parent > child. So what you need is to change the background color and color on hover of li.
.dropDownMenu a:hover {
color: #000;
background: #fff;
}
What i did is, i give css on hover of your dropdown menu. You can do it for more child according to > selector.
Try this, on particular row hover effect as below:
And change background-color for currency li hover green to white.
.dropDownMenu > li > ul {
background: white none repeat scroll 0 0;
display: block !important;
left: 0;
position: absolute;
text-align: left;
top: 100%;
width: 240px;
z-index: 999999;
}
ul.dropDownMenu li ul li:hover {
background-color: green;
}
Just add following css will make like your expected output.
#select-language ul li:hover
{
background-color:white
}
Related
This is a two part question. The first part is my problem when hovering over an li element that is supposed to reveal a nested ul element. It brings the rest of the li tags at the bottom of the nested ul element. I don't know what I'm doing wrong but it pushes the initial li elements downward. I wish someone can explain what I'm doing wrong. Here is the code
The second question I have is how do I create li elements that specificly have a hovering effect on them and not any nested li elements? I wanted to create a menu list that changes the color of the text when you hover over it, but I didn't want the nested li elements to also have the hover effect
HTML
<div id="container">
<ul class="list-inline">
<li>Fire
<ul>
<li>charmander</li>
<li>magmar</li>
<li>vulpix</li>
</ul>
</li>
<li>Grass
<ul>
<li>bulbasaur</li>
<li>bellsprout</li>
<li>oddish</li>
</ul>
</li>
<li>Electric
<ul>
<li>pichu</li>
<li>magneton</li>
<li>voltorb</li>
</ul>
</li>
<li>Water
<ul>
<li>squirtle</li>
<li>poliwag</li>
<li>krabby</li>
</ul>
</li>
</ul>
</div>
SCSS
$green: #33cc33;
$blue : #0099ff;
$yellow: #ffcc00;
$red: #ff3333;
#mixin secondUl($color) {
li {
color: white;
background: $color;
min-width: 100px;
border-bottom: 1px solid white;
}
a {
color: white;
font-weight: normal;
text-align: center;
display: block;
width:100% ;
padding: 5px 0;
}
} //secondUl
#container {
width: 600px;
margin: auto;
margin-top: 30px;
border-top: 1px solid black;
color: black;
font-family: arial,
sans-serif;
ul {
margin: 15px 0;
position: relative;
} //ul
} //container
.list-inline {
ul {
position: absolute;
padding: 0;
top: 0;
left: -25% ;
z-index: 2;
display: none;
li {
display: inherit;
min-width: 100px;
margin: 0;
} //li
} //ul
li:nth-of-type(1) ul {
#include secondUl($red);
}
li:nth-of-type(2) ul {
#include secondUl($green);
}
li:nth-of-type(3) ul {
#include secondUl($yellow);
}
li:nth-of-type(4) ul {
#include secondUl($blue);
}
li {
list-style: none;
display: inline-block;
margin: 0 10px;
&:hover ul {
display: block;
}
} //li
li:nth-child(1) a:hover {
color: $red;
}
li:nth-child(2) a:hover {
color: $green;
}
li:nth-child(3) a:hover {
color: $yellow;
}
li:nth-of-type(4) a:hover {
color: $blue;
}
&:first-child a {
text-decoration: none;
color: black;
text-transform: capitalization;
font-weight: 600;
-webkit-transition: color 1s;
transition: color 1s;
-moz-transition: color 1s;
}
}//list-inline
First you have used global css for ul under #container #container ul {position:relative;} this css will be apply on every child ul which is in #container, and its overriding .list-inline ul{position:absolute}, you need to set immediate child selector css #container > ul {position:relative;}.
For second ans. you need to do same thing, use immediate child selector css
http://codepen.io/anon/pen/LRZVRO
For problem 1 add vertical-align:top to your li
li {
list-style: none;
display: inline-block;
margin: 0 10px;
vertical-align: top;
&:hover ul {
display: block;
}
}
For Problem 2 use child instead of decendant selector. E.G:
> li:nth-child(1)>a:hover {
color: $red;
}
See: http://codepen.io/anon/pen/rrpVaV
It works well. you have to add width of li
.list-inline li {
min-width: 110px;
}
And
.list-inline li:hover ul {
display: table;
}
DEMO
https://codepen.io/Dhaarani/pen/vXpONj
I'm trying to create a site navigation bar that uses sub-menus.
Using whatever I can gather from the internet I've done my best and have got one working with one small issue.
When you hover the mouse over the sub-menu, the main menu text colour does not stay white like I'd like it to.
Can anyone get this to work?
.header nav.site_nav {
float: right;
}
.header ul {
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
.header ul a {
display: block;
font-weight: bold;
color: #2C395D;
font-size: 14px;
text-decoration: none;
padding: 8px 8px 8px 8px;
}
.header ul a:hover {
color: white;
}
.header ul li {
float: left;
position: relative;
margin: 0 2px 0 2px;
}
.header ul li:hover {
background: #2C395D;
}
.header ul ul {
display: none;
position: absolute;
text-align: right;
top: 100%;
right: 0;
}
.header ul ul li {
float: none;
width: 150px;
background: #BFC8E1;
margin: 0;
}
.header ul li:hover > ul {
display: block;
}
jsfiddle code
I wasn't able to do this easily without adding more information to your html. I added a class to all top level menu items, then added a small amount of css to make them white on hover.
Updated Fiddle
Add this class to your top level menu items in html:
<a class="topLevel" href="#">Courses ▾</a>
Add this to your CSS:
.header ul li:hover a.topLevel {
color: white;
}
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'm trying to keep the parent nav background active when on child page.
Example: Portfolio---->Programs
When my current page is Programs, I'd like to keep the Portfolio active on the navigation bar.
The code use in the CSS is:
/* Navigation
--------------------------------------------------------------------------------*/
#nav-wrap {
max-height: 200px;
}
#nav .container ul {
list-style: none !important;
}
#nav .container ul li {
list-style: none !important;
}
#nav .container ul span:last-child li,
#nav .container ul > li:last-child {
/*background: none;*/
background:url(surf_40.gif) no-repeat -12px;
}
#nav ul li a {
display: block;
font-size:30px;
line-height: 35px;
padding: 10px 0;
color: rgba(255,255,255,0.4);
padding: 2px 25px 2px 21px;
border: 0;
outline: 0;
list-style-type: none;
position:relative;
right:-4px;
z-index:1;
text-transform: uppercase;
font-family: 'Aller', sans-serif;
}
#nav ul li#active a {
background: url(surf_40.gif) no-repeat -12px;
}
#nav ul li#active a,
#nav ul li a:hover {
color: #fff;
border: 0;
}
/**Text modified added - for active parent while my current page is a sub-menu***/
#wsite-menus .wsite-menu li #active a #nav ul li a {
color: #fff;
border: 0;
}
/*---*/
/* Navigation Submenu's
--------------------------------------------------------------------------------*/
#wsite-menus .wsite-menu li a {
color: rgba(0,0,0,0.4);
font-weight: bold;
background: #fff;
/*border: 0 px;*/
border: solid thick;
border-radius: 1em;
/* fine modifica*/
position:relative;
right: 0 px;
}
#wsite-menus .wsite-menu li a:hover {
color: #000;
background: #e3e3e3;
border: solid thick orange;
}
thank you for any help..
HTML code:
<div id="nav">
<ul class='wsite-menu-default'>
<li id='pg962547086691527768'><a href="/" data-membership-required="0" >Home</a></li>
<li id='pg623326219140352077'><a href="/about.html" data-membership-required="0">About</a</li>
</ul></div>
Put the :hover on li's instead of a:hover and alos add class active to li. if you provide html two then i will provide you the perfect solution thanks
i try to make my blog responsive but my navigator menu is behind the title, i want to make it in front of my title. you can look the print screen here
print-screen
and here's the nav code on media query;
.nav {
max-width:599px;
position: relative;
float:center;
padding-bottom:120px;
top:159px;
left:-60px;
min-height: 40px;
padding-top:0;
}
.nav ul {
/*width: 599px;*/
padding: 5px 0;
position: absolute;
/*top: -13px;
left: -95px;*/
border: solid 1px #2FB8C8;
background: #2FB8C8 url(../images/icon-menu.png) no-repeat 10px 11px;
}
.nav li {
display: none; /* hide all <li> items */
margin: 0;
opacity:0.8;
}
.nav .current {
display: block; /* show only current <li> item */
}
.nav a {
display: block;
padding: 5px 5px 5px 32px;
text-align: left;
width:599px;
}
.nav .current a {
background: none;
color: #666;
}
/* on nav hover */
.nav ul:hover {
opacity:1;
}
.nav ul:hover li {
display: block;
margin: 0 0 5px;
}
.nav ul:hover .current {
background: url(../images/icon-check.png) no-repeat 10px 7px;
}
thanks in advance for your help
You could set the z-index explicitly to bring those elements forward.
.nav {
z-index:2
max-width:599px;
position: relative;
float:center;
padding-bottom:120px;
top:159px;
left:-60px;
min-height: 40px;
padding-top:0;
}
.Title{
/*or what ever you gave it*/
z-index:1;
}
Check the following links for your guide. You also need to use jQuery.
http://tympanus.net/codrops/2013/04/19/responsive-multi-level-menu/
http://webdesignerwall.com/demo/responsive-menu/
http://www.hongkiat.com/blog/responsive-web-nav/