CSS not modifying link properties

前端 未结 5 1420
离开以前
离开以前 2020-12-22 13:41

Whatever I try to do, I can\'t modify the color of my links ( want to create a color rollover effect). They always stay the same default blue color with the underline effec

相关标签:
5条回答
  • 2020-12-22 14:01

    I think it has to do with the fact that you are not referencing your ul correctly, could be wrong though. Anyway take a look at this.

    <style>
    ul#navlist li{
    list-style:none;
    }
    ul#navlist li a:link {text-decoration: none}
    ul#navlist li a:visited {text-decoration: none}
    ul#navlist li a:active {text-decoration: none}
    ul#navlist li a:hover
    {
    color: #cccccc;
    background-color: #003366;
    border: 1px #ffffff inset;
    }
    
    
    
    
    </style>
    
    <div id="navcontainer">
    
    <ul id="navlist">
    <li><a href="#">Item one</a></li>
    </ul>
    
    </div>
    

    I kind of mix and mashed from my reference and your example and I think this is what you are looking for. Oh and if you didn't know by this point, your braces are messed up.

    0 讨论(0)
  • 2020-12-22 14:08

    Because your CSS only specifies the color of the links contained within the #nav <div>. All other links on page will be default color/style.

    EDIT:

    Not sure exactly which links you're talking about though. If you're talking about your navigation links, then see the others' answers pointing out the fact that you have a misplaced bracket } in your CSS.

    If you're talking about the other links on the page, see my original answer above. You have no CSS for those links.

    0 讨论(0)
  • 2020-12-22 14:17

    You missed some close-braces } that I fixed them by editing your question. Another Issue in your code is that should create css for A in this order:

    a {}
    a:link {}
    a:visited {}
    a:hover {}
    a:focus {}
    a:active {}
    

    to take effect. just change your A styles ordering and it'll work correctly.

    0 讨论(0)
  • 2020-12-22 14:23
    **#nav li {
        display:inline;
        margin:0;
        padding:0;
        width:160px;
        float:left;**
    
    
    #nav li:hover {
        background-color: #faffd8;
        border-color: #004f7b;
    
    
    }
    
    #nav a {
    
        color: #000;
        text-decoration: none;
    }
    
    
    #nav a:link {
        color: #333333;
        text-indent: -9999px;
        text-decoration: none;
    
    
    }
    
    #nav a:hover {
        color: #000000;
        text-decoration: none;
    
    
    
    }
    
    #nav a:visited{
        color: #999999;
        text-decoration: none;
    
    
    }
    
    #nav a:active {
        color: #000000;
        text-decoration: none;
    
    }
    
    **#topcontent p
    {
        color: #444444;
    
    }
    
    
    }**
    

    ** check starred CSS Styles there no closing for first CSS style also extra closing for last one

    0 讨论(0)
  • 2020-12-22 14:27

    You're missing a curly brace in this block:

    #nav li {
        display:inline;
        margin:0;
        padding:0;
        width:160px;
        float:left;
    
    0 讨论(0)
提交回复
热议问题