html - 跨浏览器填充/边距

标签 html css internet-explorer cross-browser

我想知道您能否就如何解决此问题给我一些有用的提示?我的网站上有一个主菜单,它的代码如下:

li:hover {
    background-color: #222222;
    padding-top: 8px;
    padding-bottom: 9px;
}

下面是它实际外观的演示:

menu li overflow in browsers other than IE

问题是,当我将鼠标悬停在菜单选项 (li) 上时,背景会出现,但它会溢出到菜单背景的外部,使它看起来真的很狡猾/废话/廉价/糟糕!

请注意(很明显)当我更改内边距以使其在这些浏览器中正确显示时,它在 IE 中的高度显得太小了!所以无论哪种方式我都搞砸了。我怎样才能使像这样的小瑕疵在所有浏览器中看起来都一样?

更新:

HTML(菜单):

            <ul class="menu">
                <li class="currentPage" href="index.php"><a>Home</a></li>
                <li><a href="services.php">Services</a></li>
                <li><a href="support.php">Support</a></li>
                <li><a href="contact.php">Contact Us</a></li>
                <li><a href="myaccount/" class="myaccount">My Account</a></li>
            </ul>

CSS:

.menu {
    margin-top: 5px;
    margin-right: 5px;
    width: 345px;
    float: right;
}

li {
    font-size: 9pt;
    color: whitesmoke;
    padding-left: 6px;
    padding-right: 8px;
    display: inline;
    list-style: none;
}

li:hover {
    background-color: #222222;
    padding-top: 8px;
    padding-bottom: 9px;
}

最佳答案

您可以通过不根据悬停更改填充来防止出现问题。此外,您应该将鼠标悬停在 a

这是否按预期工作? JSFiddle example

关于html - 跨浏览器填充/边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5161467/

相关文章:

javascript - 在静态 html 页面中保存计数器

css - jqwidgets 径向 guage 样式背景

javascript - 如何在以下情况下将 div 内容对齐到中心?

.net - ASP.NET 单元测试 - WatiN 和 Windows 7/Internet Explorer 8

html - 更改/修复导航栏上的字体

jquery - 纯点击滚动到

html - 当列数不同时,如何使 HTML 表格某些列中的所有单元格具有相同的宽度?

html - CSS Bootstrap : list-group-item hover+selected

javascript - 覆盖 JavaScript 会在 IE 中导致无限循环,但在 Firefox 中不会

CSS3 animation/keyframes, transforming with vw in IE11 问题