我正在尝试在网页上显示一个简单的选项卡菜单。我正在使用一个非常基本且使用良好的模式,它工作正常,除了当我在 Chrome 中测试页面时(嗯,Chromium 但 afaik 它是一样的)我看到一个我看不到的 1 像素宽的工件掩盖。
这是测试代码:
<!DOCTYPE html>
<html>
<head>
<title>One pixel menu bug</title>
<style>
body {
font-family: sans-serif;
margin: 0;
}
h1 {margin-bottom: 1em}
#menu {
padding-top: .3em;
padding-bottom: 0;
z-index: 1;
background: black;
font-size: 1em;
margin-top: 0.5em;
}
#menu ul {
list-style: none;
border: 0 none;
padding: 0;
margin-left: 2em;
border-bottom: 1px solid black;
}
#menu li {
display: inline;
margin-right: .15em;
background-color: white;
}
#menu li a {
text-decoration: none;
color: #99a;
padding: 0px 12px;
}
#menu a.selected {
font-weight: bold;
color: black;
border-bottom: 2px solid white;
}
</style>
</head>
<body>
<h1>Site title here</h1>
<div id="header">
<div id="menu">
<ul>
<li><a href="#">Are we not men?</a></li>
<li><a href="#" class="selected">We are Devo</a></li>
</ul>
</div>
</div>
<p>Lorem ipsum</p>
</body>
</html>
以及我使用 Chrome(左)和 Firefox(右)看到的结果:
删除样式声明的 font-family 行会使问题消失,但我不想对主站点这样做。欢迎对正在发生的事情进行解释或提出变通方法的建议!