如何在导航栏的下拉区域中更改文本的颜色?

时间:2019-10-10 20:17:14

标签: css dropdown

我的下拉列表中的文本非常暗,与背景的对比度不足。据我所知,该文本设置为白色,但显示为灰色。

我尝试过更改阴影以及#FFFFFF的各种实例,以尝试找出需要更改的确切代码位置。

body {
margin: 0;
padding: 0;
}
* {
font-family: 'Orbitron', sans-serif;
}
.nav-bar {
height: 70px;
background: #262626;
}

.brand {
position: absolute;
padding-left: 20px;
float: left;
line-height: 70px;
text-transform: uppercase;
font-size: 1.4em;
}
.brand a img {
max-height: 70px;
}
.brand a,
.brand a:visited {
color: #ffffff;
text-decoration: none;
}

.nav-container {
max-width: 1000px;
margin: 0 auto;
}

nav {
float: right;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
nav ul li {
float: left;
position: relative;
}
nav ul li a,
nav ul li a:visited {
display: block;
padding: 0 20px;
line-height: 70px;
background: #262626;
color: #ffffff;
text-decoration: none;
}
nav ul li a:hover,
nav ul li a:visited:hover {
background: #2ab1ce;
color: #ffffff;
}
nav ul li a:not(:only-child):after,
nav ul li a:visited:not(:only-child):after {
padding-left: 4px;
content: ' ▾';
}
nav ul li ul li {
min-width: 190px;
}
nav ul li ul li a {
padding: 15px;
line-height: 20px;
}

.nav-dropdown {
position: absolute;
display: none;
z-index: 1;
}
.nav-mobile {
display: none;
position: absolute;
top: 0;
right: 0;
background: #262626;
height: 70px;
width: 70px;
}

@media only screen and (max-width: 798px) {
.nav-mobile {
display: block;
}

nav {
width: 100%;
padding: 70px 0 15px;
}
nav ul {
display: none;
}
nav ul li {
float: none;
}
nav ul li a {
padding: 15px;
line-height: 20px;
padding-left: 25%;

}
nav ul li ul li a {
padding-left: 30%;
}

.nav-dropdown {
position: static;
}
.brand a img {
max-height: 60px;
margin-top: 5px;
}
}
@media screen and (min-width: 799px) {
.nav-list {
display: block !important;
}
}
#nav-toggle {
position: absolute;
left: 18px;
top: 22px;
cursor: pointer;
padding: 10px 35px 16px 0px;
}
#nav-toggle span,
#nav-toggle span:before,
#nav-toggle span:after {
cursor: pointer;
border-radius: 1px;
height: 5px;
width: 35px;
background: #ffffff;
position: absolute;
display: block;
content: '';
transition: all 300ms ease-in-out;
}
#nav-toggle span:before {
top: -10px;
}
#nav-toggle span:after {
bottom: -10px;
}
#nav-toggle.active span {
background-color: transparent;
}
#nav-toggle.active span:before, #nav-toggle.active span:after {
top: 0;
}
#nav-toggle.active span:before {
transform: rotate(45deg);
}
#nav-toggle.active span:after {
transform: rotate(-45deg);
}

article {
max-width: 1000px;
margin: 0 auto;
padding: 10px;
}

我希望下拉菜单中的文本显示为白色,以便在下拉背景的背景下突出显示。

1 个答案:

答案 0 :(得分:0)

这些是CSS中的颜色设置

/* default color */
nav ul li a,
nav ul li a:visited {
  background: #262626;
  color: #ffffff;
}
/* mouse over */
nav ul li a:hover,
nav ul li a:visited:hover {
  background: #2ab1ce;
  color: #ffffff;
}

您可以使用颜色名称或(十六进制)十进制表示法。 如何在https://www.w3schools.com/css/css_colors.asp