html - CSS 水平菜单 - 为什么仅在 IE 中有 1px 的边框/空间?

标签 html css internet-explorer menu html-lists

我有一个带有悬停效果的简单水平菜单。 它在 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/

相关文章:

javascript - 如何使用动态页面内容使元素静态化

javascript - 按钮表现得像固定的但如果 parent 结束可见他的位置 :end of parent

html - 我可以在纯 CSS 中创建没有列的布局吗?

javascript - 无法在 IE 中选择文本区域中的文本

javascript - 区分人类生成的事件和旧 IE 中生成的浏览器事件

java - 将动态数据从位于多个 div 下的多个表中的 JSP 页面导出到 Excel

c# - 在 View 上自动更新 ViewComponent

javascript - 在动态添加的行中突出显示所选字段会使它们消失

html - IE6 和 IE7 绝对定位的 div 在多个相对 div 之上

javascript - 单击后如何隐藏按钮