HTML / CSS - Hover Link Color

前端 未结 2 1014
猫巷女王i
猫巷女王i 2020-12-20 08:07

I have this code written in my CSS; which makes all links on my site white, and when they\'re hovered on, they turn gray.

a:link {color: #FFFFFF}
a:active {c         


        
相关标签:
2条回答
  • 2020-12-20 08:40

    Give your links an ID:

    <a id="page1" href="http://www.my-website09090909.com/page1">Page 1</a>
    <a id="page2" href="http://www.my-website09090909.com/page1">Page 2</a>
    <!-- .... -->
    

    And then use this css:

    #page1:hover { color: red; }
    #page2:hover { color: blue; }
    /* ... */
    
    0 讨论(0)
  • 2020-12-20 08:59

    Just have a parent element and according to your parent element try below :

    Just try this :

    <div id="links">
    <a href="http://www.my-website09090909.com/page1">Page 1</a> 
    <b><span class="separator">|</span></b> 
    <a href="http://www.my-website09090909.com/page2">Page 2</a> 
    <b><span class="separator">|</span></b> 
    <a href="http://www.my-website09090909.com/page3">Page 3</a> 
    <b><span class="separator">|</span></b> 
    <a href="http://www.mywebsite09090909.com/page4">Page 4</a>
    </div>
    

    And CSS Is :

    <style type="text/css">
    #links a:nth-of-type(1){color:#009900;}
    #links a:nth-of-type(1):hover{color:#ccc;}
    #links a:nth-of-type(2){color:#006699 ;}
    #links a:nth-of-type(2):hover{color:#ccc;}
    #links a:nth-of-type(3){color:#990000;}
    #links a:nth-of-type(3):hover{color:#ccc;}
    #links a:nth-of-type(4){color:#FF00CC;}
    #links a:nth-of-type(4):hover{color:#ccc;}
    </style>
    
    0 讨论(0)
提交回复
热议问题