简体   繁体   中英

CSS of anchor hover in ul and li

I have this navigation, It's working fine. But when I'm apply tags in the li, the text hover, text color effect is just getting messy. I want to apply anchor styling in the css so the text styling remain same after after apply ahrefs.

HTML

<ul class="rexademenu"><li class="rexademenu">Home</li>
  <li>About</li>
  <li>
    Portfolio
    <ul class="rexadesubmenu">
      <li>Web Design</li>
      <li>Web Development</li>
      <li>Illustrations</li>
    </ul>
  </li>
  <li>Blog</li>
  <li>Contact</li>
</ul>

CSS

.rexademenu {
  text-align: left;
  display: inline;
  margin: 0;
  padding: 15px 4px 17px 0;
  list-style: none;
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
.rexademenu  li {
  font: bold 12px/18px sans-serif;
  display: inline-block;
  margin-right: -4px;
  position: relative;
  padding: 15px 20px;
  background: #fff;
  cursor: pointer;
  -webkit-transition: all 0.2s;
  -moz-transition: all 0.2s;
  -ms-transition: all 0.2s;
  -o-transition: all 0.2s;
  transition: all 0.2s;
}
.rexademenu > li:hover {
  background: #555;
  color: #fff;
}
.rexadesubmenu  {
  padding: 0;
  position: absolute;
  top: 48px;
  left: 0;
  width: 150px;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
  display: none;
  visibility: hidden;
  -webkit-transiton: opacity 0.2s;
  -moz-transition: opacity 0.2s;
  -ms-transition: opacity 0.2s;
  -o-transition: opacity 0.2s;
  -transition: opacity 0.2s;
}
.rexadesubmenu > li { 
  background: #555; 
  display: block; 
  color: #fff;
  text-shadow: 0 -1px 0 #000;
}
.rexadesubmenu > li:hover { background: #666; }
.rexademenu > li:hover .rexadesubmenu {
  display: block;
  opacity: 1;
  visibility: visible;

http://jsfiddle.net/oyp6qkyz/2/

(answer derived from comments)

If you don't want underlining and blue color on the menu, you could add this to the css:

.rexademenu  li a, .rexademenu li a:hover {
   text-decoration: none;
   color: #AAA;
}
.rexademenu li a:hover {
   text-decoration: none;
   color: white;
}

You override the code in your global css-file with this.

Update your css like this:

Css

.rexademenu li a{
    color:#666666;
    text-decoration:none;
}
.rexademenu li a:hover, .rexademenu li:hover a{
    color:#ffffff;
}

Updated Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM