2016-07-05 143 views
0

我有一個按鈕嵌入在我的導航欄,我想知道如何改變按鈕的字體顏色,而不改變導航欄文本顏色的其餘部分。更改按鈕字體的文本顏色,在導航欄內

按鈕是在灰色文本的綠色背景。需要使綠色的白色文字保持灰色,同時保持其他標籤文字爲灰色

.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>

+1

我不太明白?你不能像剛纔那樣瞄準.button2類嗎?這將確保只有該按鈕(或具有相同類別的其他按鈕)受到影響。 –

+0

'顏色:#82b440;'改變這一點。 – Scott

+0

我試過了,它似乎是導航。 UL認證。 li字體顏色會明確地取代按鈕中的顏色更改。顏色:#82b440(綠色)實際上是無用的,因爲文本內的文本當前是灰色的,因爲那是導航。 UL認證。李。定義它是。 – Kyle

回答

2

變化.button2color屬性#FFFFFFwhite。否則,你告訴它有綠色的文字,與背景顏色相同。

+0

我試過了,它似乎是導航。 UL認證。 li字體顏色可以否定特定按鈕中的顏色更改。顏色:#82b440(綠色)實際上是無用的,因爲文本內的文本當前是灰色的,因爲那是導航。 UL認證。李。定義它是。 – Kyle

+0

嘗試使用!重要的'顏色'規則,使其覆蓋,這可能有所幫助。 – Isaac274

0

好吧,

你應該知道,負責字體顏色屬性有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>

+0

你好,出於某種原因,它似乎是那種字體的顏色。這就是定義導航欄字體顏色的方法#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

+0

我認爲繼承屬性是從它的父元素中取得的,所以在實際意義上,改變它並不會做太多的事情 –