我有一个带有悬停效果的简单水平菜单。 它在 Chrome/Firefox 中显示良好,但在 IE11 中,元素之间有一个 1px 的边框。
将鼠标悬停在左侧链接上即可看到:http://jsfiddle.net/cMeE5/
这是一个截图:IE11 Screenshot http://users.telenet.be/mhd/ie11.png
这个垂直边框并没有那么糟糕,但是相同类型的边框总是显示在菜单项的底部(但它不会在 JSFiddle 中重现)。
我还尝试添加了完整的 CSS 重置,但这并没有改变任何东西。
这是 JSFiddle 上的代码:
<div id="navcontainer">
<div id="midnav">
<ul>
<li><a href="#">Link A</a></li>
<li class="activesub"><a href="#">Link B</a></li>
</ul>
</div>
</div>
<div id="maincontainer">
<div id="main">
<h1>Test</h1>
</div>
</div>
CSS:
* { margin: 0; padding: 0;}
html { min-height: 100%; height: 100%; margin-bottom: 1px; overflow-y: scroll;}
body {
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 0.875em;
background-color: #ebebeb;
color: black;
height: 100%;
}
a, a:active, a:hover, a:visited, a:link {
text-decoration: none;
font-weight: none;
background-color: none;
color: inherit;
}
/********************/
/*** SUBNAVIGATIE ***/
/********************/
#navcontainer {
width: 100%;
background-color: #464646;
}
#midnav {
width: 1000px;
margin: 0 auto;
color: white;
padding-top: 0.3em;
}
#midnav ul {
list-style-type: none;
display: table;
}
#midnav li {
display: table-cell;
-moz-border-radius-topleft: 7px;
-webkit-border-top-left-radius: 7px;
border-top-left-radius: 7px;
-moz-border-radius-topright: 7px;
-webkit-border-top-right-radius: 7px;
border-top-right-radius: 7px;
-webkit-transition: all 0,1s ease;
-moz-transition: all 0,1s ease;
-o-transition: all 0,1s ease;
-ms-transition: all 0,1s ease;
transition: all 0,1s ease;
}
#midnav a {
display: block;
padding: 0.3em 1em 0.5em 1em;
}
.activesub, #midnav li:hover {
color: #464646;
background-color: #ebebeb;
}
/********************/
/*** MAIN CONTENT ***/
/********************/
#maincontainer {
width: 100%;
background-color: #ebebeb;
}
#main {
width: 1000px;
margin: 0 auto;
color: #464646;
}
#maincontainer p {
margin-bottom: 1em;
margin-top: 1em;
}
最佳答案
我仍然不确定是什么导致了 IE 中的问题,但底部 1px 空间的解决方案是向 LI 元素添加 1px 边框(条件 IE CSS)
#midnav li {
border-bottom: 1px solid #464646;
}
#midnav .activesub, #midnav li:hover {
border-bottom: 1px solid #ebebeb;
}
关于html - CSS 水平菜单 - 为什么仅在 IE 中有 1px 的边框/空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21945378/