2017-03-19 1 views
0

Ich habe eine Frage bezüglich der Textfarbe meines Dropdown-Menüs. Die Drop-Down-Textfarbe basiert auf der Farbe des Hauptlinks. Wenn ich diesen Link auswähle, ändert er sich in die aktuelle Tab-Farbe, ändert aber auch die Drop-Down-Textfarbe. Ich habe mich gefragt, wie man die Drop-Down-Menü-Farbe unabhängig von der Farbe des Haupt-Tab-Textes machen kann. HierAktuelle Registerkarte ändern Dropdown-Menü Farbe

ist die HTML:

<nav id="nav-wrap"> 

      <a class="mobile-btn" href="#nav-wrap" title="Show navigation">Show navigation</a> 
      <a class="mobile-btn" href="#" title="Hide navigation">Hide navigation</a> 

      <ul id="nav" class="nav"> 

       <li><a href="index.html">Home</a></li> 
       <li class="current"><a href="blog.html">Blog</a> 
       </li> 
       <li><span><a href="portfolio-index.html">Resources</a></span> 
       <ul> 
        <li><a href="alcoholre.html">Alcohol</a></li> 
        <li><a href="drugsre.html">Drugs</a></li> 
        <li><a href="mentalhealthre.html">Mental Health</a></li> 
        <li><a href="suicidere.html">Suicide</a></li> 
       </ul> 
       </li> 
       <li><a href="about.html">About</a></li> 
       <li><a href="contact.html">Contact</a></li> 

      </ul> <!-- end #nav --> 

     </nav> <!-- end #nav-wrap --> 

Und hier ist die CSS:

#nav-wrap ul, #nav-wrap li, #nav-wrap a { 
margin: 0; 
padding: 0; 
border: none; 
outline: none; 
} 

/* nav-wrap */ 
#nav-wrap { 
position: relative; 
font: 15px raleway-heavy, sans-serif; 
text-transform: uppercase; 
letter-spacing: 1.5px; 
float: right; 
margin-top: 32px; 
margin-right: 20px; 
z-index: 99999; 
} 

/* hide toggle button */ 
#nav-wrap > a.mobile-btn { 
display: none; 
border-radius: 3px; 
} 

ul#nav { 
min-height: 48px; 
width: auto; 

/* left align the menu */ 
text-align: left; 
} 
ul#nav li { 
position: relative; 
list-style: none; 
height: 48px; 
display: inline-block; 
} 

/* Links */ 
ul#nav li a { 

/* 8px padding top + 8px padding bottom + 32px line-height = 48px */ 

display: inline-block; 
padding: 8px 11px; 
line-height: 32px; 
text-decoration: none; 
text-align: left; 
color: #ffffff; 

-webkit-transition: color .2s ease-in-out; 
-moz-transition: color .2s ease-in-out; 
-o-transition: color .2s ease-in-out; 
-ms-transition: color .2s ease-in-out; 
transition: color .2s ease-in-out; 
} 

ul#nav li a:active { background-color: transparent !important; } 
ul#nav li:hover > a, 
ul#nav li.current a { color: #00b2ee; } 

/* adds down arrow */ 
ul#nav span:after { 
width: 0; 
height: 0px; 
border: 4px solid transparent; 
border-bottom: none; 
border-top-color: #00b2ee; 
content: ''; 
vertical-align: middle; 
display: inline-block; 
position: relative; 
right: 5px; 
} 

/* Sub Menu 
----------------------------------------------------- */ 
ul#nav ul { 
position: absolute; 
top: 100%; 
left: 0; 
background: #c7c7c7; 
min-width: 100%; 


border-radius: 5px 5px 7px 7px; 

/* for transition effects */ 
opacity: 0; 
filter: alpha(opacity=0); 

-webkit-transition: opacity .25s ease .1s; 
-moz-transition: opacity .25s ease .1s; 
-o-transition: opacity .25s ease .1s; 
-ms-transition: opacity .25s ease .1s; 
transition: opacity .25s ease .1s; 
} 

/* Third level sub menu 
ul#nav ul ul { 
position: absolute; 
top: 0; 
left: 100%; 

border-radius: 0 3px 3px 3px; 
} 
*/ 

ul#nav ul li { 
padding: 0; 
display: block; 
text-align: left; 

/* for transition effects */ 
height: 0; 
overflow: hidden; 

-webkit-transition: height .25s ease .1s; 
-moz-transition: height .25s ease .1s; 
-o-transition: height .25s ease .1s; 
-ms-transition: height .25s ease .1s; 
transition: height .25s ease .1s; 
} 

/*On Hover */ 
ul#nav li:hover > ul { 
opacity: 1; filter: alpha(opacity=100); 
} 
ul#nav li:hover > ul li { 
height: 42px; 
overflow: visible; 
border-bottom: 1px solid #26272C; 
color: #ffffff; 
} 
ul#nav li:hover > ul li:last-child { border: none; } 

/* Sub Menu Anchor links */ 
ul#nav ul li a { 
padding: 6px 15px; 
margin: 0; 
white-space: nowrap; 
font-size: 13px; 
} 

Jede Hilfe wäre genial!

Antwort

0

fügen Sie den folgenden am Ende Ihres CSS-Skript

ul#nav ul li a:hover{ 
color:red; 
} 

Beispiel:

#nav-wrap ul, #nav-wrap li, #nav-wrap a { 
 
margin: 0; 
 
padding: 0; 
 
border: none; 
 
outline: none; 
 
} 
 

 
/* nav-wrap */ 
 
#nav-wrap { 
 
position: relative; 
 
font: 15px raleway-heavy, sans-serif; 
 
text-transform: uppercase; 
 
letter-spacing: 1.5px; 
 
float: right; 
 
margin-top: 32px; 
 
margin-right: 20px; 
 
z-index: 99999; 
 
} 
 

 
/* hide toggle button */ 
 
#nav-wrap > a.mobile-btn { 
 
display: none; 
 
border-radius: 3px; 
 
} 
 

 
ul#nav { 
 
min-height: 48px; 
 
width: auto; 
 

 
/* left align the menu */ 
 
text-align: left; 
 
} 
 
ul#nav li { 
 
position: relative; 
 
list-style: none; 
 
height: 48px; 
 
display: inline-block; 
 
} 
 

 
/* Links */ 
 
ul#nav li a { 
 

 
/* 8px padding top + 8px padding bottom + 32px line-height = 48px */ 
 

 
display: inline-block; 
 
padding: 8px 11px; 
 
line-height: 32px; 
 
text-decoration: none; 
 
text-align: left; 
 
color: #ffffff; 
 

 
-webkit-transition: color .2s ease-in-out; 
 
-moz-transition: color .2s ease-in-out; 
 
-o-transition: color .2s ease-in-out; 
 
-ms-transition: color .2s ease-in-out; 
 
transition: color .2s ease-in-out; 
 
} 
 

 
ul#nav li a:active { background-color: transparent !important; } 
 
ul#nav li:hover > a, 
 
ul#nav li.current a { color: #00b2ee; } 
 

 
/* adds down arrow */ 
 
ul#nav span:after { 
 
width: 0; 
 
height: 0px; 
 
border: 4px solid transparent; 
 
border-bottom: none; 
 
border-top-color: #00b2ee; 
 
content: ''; 
 
vertical-align: middle; 
 
display: inline-block; 
 
position: relative; 
 
right: 5px; 
 
} 
 

 
/* Sub Menu 
 
----------------------------------------------------- */ 
 
ul#nav ul { 
 
position: absolute; 
 
top: 100%; 
 
left: 0; 
 
background: #c7c7c7; 
 
min-width: 100%; 
 

 

 
border-radius: 5px 5px 7px 7px; 
 

 
/* for transition effects */ 
 
opacity: 0; 
 
filter: alpha(opacity=0); 
 

 
-webkit-transition: opacity .25s ease .1s; 
 
-moz-transition: opacity .25s ease .1s; 
 
-o-transition: opacity .25s ease .1s; 
 
-ms-transition: opacity .25s ease .1s; 
 
transition: opacity .25s ease .1s; 
 
} 
 

 
/* Third level sub menu 
 
ul#nav ul ul { 
 
position: absolute; 
 
top: 0; 
 
left: 100%; 
 

 
border-radius: 0 3px 3px 3px; 
 
} 
 
*/ 
 

 
ul#nav ul li { 
 
padding: 0; 
 
display: block; 
 
text-align: left; 
 

 
/* for transition effects */ 
 
height: 0; 
 
overflow: hidden; 
 

 
-webkit-transition: height .25s ease .1s; 
 
-moz-transition: height .25s ease .1s; 
 
-o-transition: height .25s ease .1s; 
 
-ms-transition: height .25s ease .1s; 
 
transition: height .25s ease .1s; 
 
} 
 

 
/*On Hover */ 
 
ul#nav li:hover > ul { 
 
opacity: 1; filter: alpha(opacity=100); 
 
} 
 
ul#nav li:hover > ul li { 
 
height: 42px; 
 
overflow: visible; 
 
border-bottom: 1px solid #26272C; 
 
color: #ffffff; 
 
} 
 
ul#nav li:hover > ul li:last-child { border: none; } 
 

 
/* Sub Menu Anchor links */ 
 
ul#nav ul li a { 
 
padding: 6px 15px; 
 
margin: 0; 
 
white-space: nowrap; 
 
font-size: 13px; 
 
} 
 
ul#nav ul li a:hover{ 
 
color:red; 
 
}
<nav id="nav-wrap"> 
 

 
      <a class="mobile-btn" href="#nav-wrap" title="Show navigation">Show navigation</a> 
 
      <a class="mobile-btn" href="#" title="Hide navigation">Hide navigation</a> 
 

 
      <ul id="nav" class="nav"> 
 

 
       <li><a href="index.html">Home</a></li> 
 
       <li class="current"><a href="blog.html">Blog</a> 
 
       </li> 
 
       <li><span><a href="portfolio-index.html">Resources</a></span> 
 
       <ul> 
 
        <li><a href="alcoholre.html">Alcohol</a></li> 
 
        <li><a href="drugsre.html">Drugs</a></li> 
 
        <li><a href="mentalhealthre.html">Mental Health</a></li> 
 
        <li><a href="suicidere.html">Suicide</a></li> 
 
       </ul> 
 
       </li> 
 
       <li><a href="about.html">About</a></li> 
 
       <li><a href="contact.html">Contact</a></li> 
 

 
      </ul> <!-- end #nav --> 
 

 
     </nav> <!-- end #nav-wrap -->

+0

Super, das hat funktioniert! Ich danke dir sehr! – epalm18

0

ich die fiddle Code erstellt. Wenn Sie den Mauszeiger über die Dropdown-Menü-Links bewegen, ändert sich die Textfarbe in Blau, das auf der aktuellen Menü-Registerkarte verwendet wird. Wenn Sie nicht möchten, dass der blaue Text im Dropdownmenü angezeigt wird und Sie die weißen Textlinks verwenden möchten, entfernen Sie einfach "ul # nav li: hover> a" aus Ihrem Code und es wird das tun Arbeit.

nun Ihre neue CSS-Code sollte wie folgt aussehen: -

#nav-wrap ul, #nav-wrap li, #nav-wrap a { 
margin: 0; 
padding: 0; 
border: none; 
outline: none; 
} 

/* nav-wrap */ 
#nav-wrap { 
position: relative; 
font: 15px raleway-heavy, sans-serif; 
text-transform: uppercase; 
letter-spacing: 1.5px; 
float: right; 
margin-top: 32px; 
margin-right: 20px; 
z-index: 99999; 
} 

/* hide toggle button */ 
#nav-wrap > a.mobile-btn { 
display: none; 
border-radius: 3px; 
} 

ul#nav { 
min-height: 48px; 
width: auto; 

/* left align the menu */ 
text-align: left; 
} 
ul#nav li { 
position: relative; 
list-style: none; 
height: 48px; 
display: inline-block; 
} 

/* Links */ 
ul#nav li a { 

/* 8px padding top + 8px padding bottom + 32px line-height = 48px */ 

display: inline-block; 
padding: 8px 11px; 
line-height: 32px; 
text-decoration: none; 
text-align: left; 
color: #ffffff; 

-webkit-transition: color .2s ease-in-out; 
-moz-transition: color .2s ease-in-out; 
-o-transition: color .2s ease-in-out; 
-ms-transition: color .2s ease-in-out; 
transition: color .2s ease-in-out; 
} 

ul#nav li a:active { background-color: transparent !important; } 
ul#nav li.current a { color: #00b2ee; } 

/* adds down arrow */ 
ul#nav span:after { 
width: 0; 
height: 0px; 
border: 4px solid transparent; 
border-bottom: none; 
border-top-color: #00b2ee; 
content: ''; 
vertical-align: middle; 
display: inline-block; 
position: relative; 
right: 5px; 
} 

/* Sub Menu 
----------------------------------------------------- */ 
ul#nav ul { 
position: absolute; 
top: 100%; 
left: 0; 
background: #c7c7c7; 
min-width: 100%; 


border-radius: 5px 5px 7px 7px; 

/* for transition effects */ 
opacity: 0; 
filter: alpha(opacity=0); 

-webkit-transition: opacity .25s ease .1s; 
-moz-transition: opacity .25s ease .1s; 
-o-transition: opacity .25s ease .1s; 
-ms-transition: opacity .25s ease .1s; 
transition: opacity .25s ease .1s; 
} 

/* Third level sub menu 
ul#nav ul ul { 
position: absolute; 
top: 0; 
left: 100%; 

border-radius: 0 3px 3px 3px; 
} 
*/ 

ul#nav ul li { 
padding: 0; 
display: block; 
text-align: left; 

/* for transition effects */ 
height: 0; 
overflow: hidden; 

-webkit-transition: height .25s ease .1s; 
-moz-transition: height .25s ease .1s; 
-o-transition: height .25s ease .1s; 
-ms-transition: height .25s ease .1s; 
transition: height .25s ease .1s; 
} 

/*On Hover */ 
ul#nav li:hover > ul { 
opacity: 1; filter: alpha(opacity=100); 
} 
ul#nav li:hover > ul li { 
height: 42px; 
overflow: visible; 
border-bottom: 1px solid #26272C; 
color: #ffffff; 
} 
ul#nav li:hover > ul li:last-child { border: none; } 

/* Sub Menu Anchor links */ 
ul#nav ul li a { 
padding: 6px 15px; 
margin: 0; 
white-space: nowrap; 
font-size: 13px; 
} 

Falls Sie eine andere Farbe verwenden möchten, während sie über die Drop-Down-Textlinks schweben, müssen Sie in der CSS-Code separat verwenden: -

ul#nav li:hover > a {color:your color name or color code} 
+0

Super! Ich habe versucht, das zu benutzen, aber ich benutzte es im falschen Teil. Ich habe es wie du gesagt, und es funktioniert jetzt! Danke für Ihre Hilfe! – epalm18

+0

@ epalm18 Gern geschehen! Froh, dass ich helfen kann :) –

Verwandte Themen