我不确定这是否真的是 Google Chrome 的错误,但会发生以下情况:
当我将伪类嵌套在一个类中时a:link
,页面中的a:visited
所有<a>
元素都将获得嵌套中设置的最新颜色。它只发生在颜色属性上。在其他浏览器中不会发生,我使用的是 Google Chrome 30.0.1599.69 m
CSS:
.cat ul{
list-style-type:none;
margin-top:10px;
padding-left:10px;
}
.cat a:link, a:visited {
margin-top: 3px;
font:15px arial,sans-serif;
display:block;
color:#000000;
text-align:left;
text-decoration:none;
}
.cat a:hover,a:active {
background-color: #eeeeee;
}
.menu ul {
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
.menu li {
float:left;
}
.menu a:link,a:visited {
height:35px;
padding-top:8px;
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#2d0000;
text-align:center;
text-decoration:none;
text-transform:uppercase;
}
.menu a:hover,a:active {
background-color:#7A991A;
}
HTML:
<html>
<head>
<title>TITLE</title>
</head>
<link href="style.css" rel="stylesheet" type="text/css" media="all" />
<body>
<div id="wrapper">
<div id="site">
<div id="header">
<div id="logo"><img src="./img/logo.png" /></div>
<div id="cart"></div>
</div>
<div id="subheader">
<div id="menu" class="menu">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
</ul>
</div>
<div id="searchbar">
<form>
<input type="text" name="search" /> <input type="submit" name="ok" value="Search" />
</form>
</div>
</div>
<div id="body">
<div id="category" class="cat">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</div>
<div id="main">
<a>Test</a>
</div>
</div>
<div id="footer"></div>
</div>
</div>
</body>
</html>