我希望最后一个菜单项是蓝色的,我正在尝试使用伪类 a:last child
来实现这一点。奇怪的是,它将规则应用于菜单中间看似随机的 a:link
。你能告诉我为什么吗?
网站: http://www.robert-wright-books.com/STAGE
CSS:
#access {
background: transparent;
float: left;
font-size: 1.4em;
text-transform: uppercase;
overflow: hidden;
width: 238px;
margin: 36px 0 0 18px;
}
#access a:last-child { color: #006ccf }
#access ul {
list-style-type: none;
margin: 0;
padding: 0;
margin-bottom: 0;
}
#access ul li { border-bottom: 1px dotted #957e5e }
#access ul li:last-child { border-bottom: none }
#access ul li a,
#access ul li a:hover,
#access ul li a:visited {
color: #432f00;
display: block;
padding: 6px 24px;
line-height: 17px;
text-decoration: none;
}
最佳答案
考虑到 #access a
是 #access 的唯一
其余链接都包含在 a
子级,LI 中
,因此 LI
是 child ,而不是 A
。
#access ul li:last-child a
指向最后一个菜单项。
关于html - 伪类 :last-child weirdness,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5628023/