2012-03-22 12 views
0

私はcssについてはあまりよく分かりませんが、ちょっとしたことがあります。フォントの色をホバーのライトブルーに変更したい。しかし、私はデフォルトの色を白にしたいと思います...私はこれをどのようにしますか?私が今持っているもの、...紫にデフォルトのテキストを変更し、下線あります。■それはホバー上で、しかし青にフォントを変更するん..テキストの上にマウスを置いたときのフォント色の変更

コード:

CSS:

a:hover 
{ 
    text-decoration:none; 
    color: #B9D3EE; 
} 

.navigationBar 
{ 

    background: gray; 
    height: 50px; 
    width: 100%; 
} 
.menuOption 
{ 
    width:143px; 
    text-align: center; 
    position: static; 
    float:left; 

} 
#search 
{ 
    position:relative; 
    font-weight: bold; 
    color: white; 
    height: 27px; 
    margin-left: 23px; 
    left: 133px; 
    top: -17px; 
    margin-top: 1px; 
} 
#reports 
{ 
    position:relative; 
    font-weight: bold; 
    color: white; 
    height: 27px; 
    margin-left: 23px; 
    left: 34px; 
    top: -16px; 
    margin-top: 1px; 
} 
#addProject 
{ 
    position:relative; 
    font-weight: bold; 
    color: #B9D3EE; 
    height: 27px; 
    margin-left: 23px; 
    left: -542px; 
    top: -18px; 
    margin-top: 1px; 
} 
#editProject 
{ 
    position:relative; 
    font-weight: bold; 
    color: white; 
    height: 27px; 
    margin-left: 23px; 
    left: -611px; 
    top: -18px; 
    margin-top: 1px; 
} 
#more 
{ 
    position:relative; 
    font-weight: bold; 
    color: white; 
    height: 27px; 
    margin-left: 23px; 
    left: -66px; 
    top: -15px; 
    margin-top: 1px; 
} 

HTML:

<div class = "navigationBar"> 

      <asp:ImageButton ID="ImageButton1" runat="server" Height="18px" 
       ImageUrl="~/g.png" style="margin-left: 1012px; margin-top: 18px" 
       Width="23px" /> 

      <div id = "search" class = "menuOption" > 
      <a href=""> Search </a> 
      </div> 

      <div id = "reports" class = "menuOption" > 
      <a href=""> Reports </a> 
      </div> 

      <div id = "more" class = "menuOption" > 
      <a href=""> More... </a> 
      </div> 

      <div id = "addProject" class = "menuOption" > 
      <a href=""> Add Project </a> 
      </div> 


      <div id = "editProject" class = "menuOption" > 
      <a href=""> Edit Project </a> 
      </div> 

</div> 

答えて

5
a:link 
{ 
text-decoration:none; 
color: #B9D3EE; 
} 
a:visited 
{ 
text-decoration:none; 
color: #B9D3EE; 
} 
a:hover 
{ 
text-decoration:none; 
color: #B9D3EE; 
} 
a:active 
{ 
text-decoration:none; 
color: #B9D3EE; 
} 

また、これはあなたのためにこれをクリアする擬似クラスのリファレンスです。待って@Brettに似ていますが、

a{ 
    text-decoration:none; 
    color:#FFF; 
} 

a:hover 
{ 
    text-decoration:none; 
    color: #B9D3EE; 
} 

それは紫だった理由をより簡潔

http://www.w3schools.com/css/css_pseudo_classes.asp

+0

大丈夫おかげで、...しかし、ただ好奇心から...どこから紫色の下線付きの文字色/スタイルを取得したのですか? .. – BigBug

+1

デフォルトでは紫色の「訪問済み」リンクです。 4つのpsuedo要素すべてを表示するために私の答えを再度編集しました。それぞれの色を変更して、その効果を確認します。 –

+0

うん...しかし、何かがクリックされる前に紫色が発生していた...?私はまた、私のCSSで "訪問された"コードを持っていなかった...方法で応答のためにありがとう:) – BigBug

2

は、デフォルトでは、ハイパーリンクが青であるため、ですが、それらが訪問される際には、紫色のターン。あなたの場合、 ""のURLは基本的に現在のページです。これはよく訪れたページです。 :)

編集不要な疑似クラス削除する:H/Tの@yunzen作品

+0

'a'だけ必要です。それにはすべての疑似クラスがあります。あなたが単に 'a:hover'や' a:link'を選択した場合、visitedは却下されません – HerrSerker