更改按钮字体的文本颜色,在导航栏内
我有一个按钮嵌入在我的导航栏,我想知道如何改变按钮的字体颜色,而不改变导航栏文本颜色的其余部分。更改按钮字体的文本颜色,在导航栏内
按钮是在灰色文本的绿色背景。需要使绿色的白色文字保持灰色,同时保持其他标签文字为灰色
.button2 {
-moz-appearance: none;
-webkit-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
background: #82b440;
border-radius: 1em;
border: solid;
border-color: #82b440;
color: #82b440;
cursor: pointer;
display: inline-block;
height: 4em;
padding: 0em 1.3em;
letter-spacing: 1px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
font-size: 1.4em;
text-decoration-color: white;
-moz-transition: all 0.35s ease-in-out;
-webkit-transition: all 0.35s ease-in-out;
-o-transition: all 0.35s ease-in-out;
-ms-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
}
<div id="header">
<div class="container">
<!-- Logo -->
<a href="index">
<img src="images/Picture2.png">
</a>
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="page">Other Page Text</a>
</li>
**
<li><a href="quote" class="button2">Button Text</a>
</li>**
</ul>
</nav>
</div>
</div>
好吧,
你应该知道,负责字体颜色属性有color:
如此改变,如果别的东西会改变字体颜色,不破坏任何东西
EG。
color: #F5F5F5;
.button2 {
-moz-appearance: none;
-webkit-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
background: #82b440;
border-radius: 2px;
border: 1px solid #82b440;
color: #f5f5f5; /* What matters here */
cursor: pointer;
display: inline-block;
padding: 10px;
padding-left: 20px;
padding-right: 20px;
box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.4);
letter-spacing: 1px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
font-size: 1.4em;
text-decoration-color: white;
-moz-transition: all 0.35s ease-in-out;
-webkit-transition: all 0.35s ease-in-out;
-o-transition: all 0.35s ease-in-out;
-ms-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
}
.button2:hover{
border: 1px solid #8fc04e;
background: #8fc04e;
box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.65);
}
<a href="#quote" class="button2">Button Text</a>
你好,出于某种原因,它似乎是那种字体的颜色。这就是定义导航栏字体颜色的方法#nav> ul> li a颜色:inherit; \t \t \t \t \t line-height:4em; \t \t \t \t \t letter-spacing:2px; \t \t \t \t \t text-decoration:none; \t \t \t \t \t text-transform:uppercase; \t \t \t \t \t font-weight:400; \t \t \t \t \t font-size:.8em; } – Kyle
我认为继承属性是从它的父元素中取得的,所以在实际意义上,改变它并不会做太多的事情 –
我不太明白?你不能像刚才那样瞄准.button2类吗?这将确保只有该按钮(或具有相同类别的其他按钮)受到影响。 –
'颜色:#82b440;'改变这一点。 – Scott
我试过了,它似乎是导航。 UL认证。 li字体颜色会明确地取代按钮中的颜色更改。颜色:#82b440(绿色)实际上是无用的,因为文本内的文本当前是灰色的,因为那是导航。 UL认证。李。定义它是。 – Kyle