0

我已经重新格式化了现成的下拉菜单并添加了一些线性动画,但是我在一些元素的颜色上遇到了问题,例如:“Tab4_5”、“Tab3_3”、“Tab1_2”、“Tab1_3”

这是我的 HTML 文件:

<!DOCTYPE html>
<html dir="rtl">
    <head>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" charset="utf-8" />
        <link rel="stylesheet" type="text/css" href="style_colors.css">
        <title>My Page Title</title>
    </head>

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

                    <li><a href="contactus.html"><span>Tab1</span></a>
                        <ul class="menu-hover" id="myID">
                            <li><a href="">Tab1_1</a></li>
                            <li><a href="">Tab1_2</a></li>
                            <li><a href="">Tab1_3</a></li>
                        </ul>
                    </li>

                    <li><a href="volunteer.html"><span>Tab2</span></a>
                        <ul class="menu-hover">
                            <li><a href="">Tab2_1</a></li>
                            <li><a href="">Tab2_2</a></li>
                        </ul>
                    </li>

                    <li><a href="candidates.html"><span>Tab3</span></a>
                        <ul class="menu-hover">
                            <li><a href="">Tab3</a></li>
                            <li><a href="">Tab3_1</a></li>
                            <li><a href="">Tab3_2</a></li>
                            <li><a href="">Tab3_3</a></li>
                        </ul>
                    </li>

                    <li><a href=""><span>Tab4</span></a>
                        <ul class="menu-hover">
                            <li><a href="">Tab4_1</a></li>
                            <li><a href="">Tab4_2</a></li>
                            <li><a href="">Tab4_3</a></li>
                            <li><a href="">Tab4_4</a></li>
                            <li><a href="">Tab4_5</a></li>
                        </ul>
                    </li>


                    <li><a href="vision.html"><span>Tab5</span></a>
                        <ul class="menu-hover">
                            <li><a href="">Tab5_1</a></li>
                            <li><a href="">Tab5_2</a></li>
                            <li><a href="">Tab5_3</a></li>
                            <li><a href="">Tab5_4</a></li>
                            <li><a href="">Tab5_5</a></li>
                        </ul>
                    </li>
              </ul>


    </body>
</html>

这是我的 CSS3 文件:

@charset "utf-8";
/* CSS Document */

* {
    margin:0px;
    padding:0px;
}
body {
    background:#f4f4f4;
}

#nav {
    width:933px;
    margin:0 auto;
    height:250px;
    padding-top:20px;
}

#nav li {
    background:#2a2a2a;
    list-style: none;
    height: 44px;
    float:left;
    padding:10px 5px;
}
#nav li a {
    width: 175px;
    height: 40px;
    line-height: 53px;
    border-bottom: 4px solid #636393;
    padding:0px;
    color: #fff;
    font-size:18px;
    font-weight:lighter;
    text-align:center;
    text-decoration: none;
    display: block;
     -webkit-transition: .2s all linear;
     -moz-transition: .2s all linear;
     -o-transition: .2s all linear;
     transition: .2s all linear;
}

#nav li a:visited {
color:#fff;
}


#nav li:nth-child(1) a , #myID li:nth-child(1) a , #myID li:nth-child(2) a , #myID li:nth-child(3) a
{
border-color: #636393;
}

#nav li:nth-child(2) a {
border-color: #B5222D;
}
#nav li:nth-child(3) a {
border-color: #D4953C;
}
#nav li:nth-child(4) a {
border-color: #609491;
}
#nav li:nth-child(5) a {
border-color: #87A248;
}

#nav li:nth-child(1) a:hover {
border-bottom: 35px solid #636393;
 height: 9px;
 color: #fff;
}

#nav li:nth-child(2) a:hover {
border-bottom: 35px solid #B5222D;
 height: 9px;
 color: #fff;
}
#nav li:nth-child(3) a:hover {
border-bottom: 35px solid #D4953C;
 height: 9px;
 color: #fff;
}

#nav li:nth-child(4) a:hover {
border-bottom: 35px solid #609491;
 height: 9px;
 color: #fff;
}

#nav li:nth-child(5) a:hover {
border-bottom: 35px solid #87A248;
 height: 9px;
 color: #fff;
}



.menu li{
list-style: none;
float: left;
position: relative;
height: 40px;
}

.menu>li{
background-color: #a82222;
background-image: -webkit-linear-gradient(#a82222, #670000);
background-image: -moz-linear-gradient(#a82222, #670000);
background-image: -o-linear-gradient(#a82222, #670000);
background-image: linear-gradient(#a82222, #670000);
border-left: 1px solid #5f5f5f;
border-right: 1px solid #7e0000;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out; 
}

.menu li:first-child{
border-radius: 3px 0px 0px 3px;
border-left: none;
}

 .menu li:last-child{
border-radius: 0px 3px 3px 0px;
 border-right: none;
 }

.menu a{
display: block;
text-decoration: none;
color: white;
text-transform: uppercase;
padding: 0 20px;
font-family: 'Verdana', arial;
margin: 0;
position: relative;
font-size: 12px;
line-height: 40px;
}

.menu li:hover{
-webkit-box-shadow: inset 0 0 10px #470000;
-moz-box-shadow: inset 0 0 10px #470000;
box-shadow: inset 0 0 10px #470000;
background-color: #a82222;
background-image: -webkit-linear-gradient(#911212, #670000);
background-image: -moz-linear-gradient(#911212, #670000);
background-image: -o-linear-gradient(#911212, #670000);
background-image: linear-gradient(#911212, #670000);
}

.menu li:hover span:after{
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);
}

ul.menu-hover{
visibility: hidden;
position: absolute;
top:100%;
opacity: 0;
height: 0;
width: 150px;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}

.menu li:hover .menu-hover{
visibility: visible;
height: 100%;
opacity: 1;
}

.menu-hover li{
height: 100%;
border-bottom: 1px solid #696969;
background-color: #2a2a2a;
border-left: none;
border-right: none;
}

.menu-hover li:hover{
background-image: -webkit-linear-gradient(#2a2a2a, #434343);
background-image: -moz-linear-gradient(#2a2a2a, #434343);
background-image: -o-linear-gradient(#2a2a2a, #434343);
background-image: linear-gradient(#2a2a2a, #434343);
box-shadow: none;
}

.menu-hover a{
color: white;
}

.menu a span:after{
content: "";
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-bottom: 3px solid white;
position: absolute;
top: 30px;
right: 35px;

-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out; 
}

.menu-hover li:first-child, .menu-hover li:last-child{
border-radius: 0;
}

.menu a:after {
    background: rgba(255,255,255,.07);
    content: "";
    height: 20px;
    left: 0;
    position: absolute;
    width: 100%;
}
4

1 回答 1

0

试试这个:

#nav li:nth-of-type(1) ul li a
{
  border-color: #636393;
}

#nav li:nth-of-type(2) ul li a, #nav li:nth-of-type(2) a {
 border-color: #B5222D;
}
#nav li:nth-of-type(3) ul li a, #nav li:nth-of-type(3) a  {
   border-color: #D4953C;
 }
#nav li:nth-of-type(4) ul li  a, #nav li:nth-of-type(4) a {
   border-color: #609491;
}
#nav li:nth-of-type(5) ul li  a, #nav li:nth-of-type(5) a {
 border-color: #87A248;
 }

#nav li:nth-of-type(1) ul li a:hover {
border-bottom: 35px solid #636393;
height: 9px;
 color: #fff;
 }

 #nav li:nth-of-type(2) ul li a:hover {
  border-bottom: 35px solid #B5222D;
   height: 9px;
  color: #fff;
  }
#nav li:nth-of-type(3) ul li a:hover {
    border-bottom: 35px solid #D4953C;
  height: 9px;
   color: #fff;
  }

#nav li:nth-of-type(4) ul li a:hover {
      border-bottom: 35px solid #609491;
     height: 9px;
     color: #fff;
 }

#nav li:nth-of-type(5) ul li a:hover {
    border-bottom: 35px solid #87A248;
    height: 9px;
     color: #fff;
 }
于 2013-06-02T21:10:56.960 回答