开发者

#nav css affecting all elements in page

开发者 https://www.devze.com 2023-02-01 18:28 出处:网络
Hey guys I set up this CSS file to use on the navbar: #nav { background-color: #98bf21; } #nav li { float:left;

Hey guys I set up this CSS file to use on the navbar:

#nav
{
    background-color: #98bf21;
    } 
#nav li
{
float:left;
}
#nav li ul{
    position: absolute;
    width: 172px;
    left: -999em;
    }

#nav li:hover ul{
    left: auto;
    }   
#nav a:link,a:visited
{
d开发者_StackOverflow中文版isplay:block;
width:164px;
font-weight:bold;
color:white;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
#nav a:hover,a:active
{
background-color: #7A991A;
}

And it seems to be affecting all the elements. For example all elements take the styles if the #nav a styles. Is there something I'm missing here? I'm new to web design.


#nav a:link,a:visited and #nav a:hover,a:active look like they could be the problem (the second selector is not bound to #nav in those lines and so will be matching all a elements. I'm assuming you mean to do #nav a:link, #nav a:visited and #nav a:hover, #nav a:active instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消