HTML/CSS : IE8 background overflowing border

标签 html css internet-explorer

在 IE8 中,我的一个按钮背景溢出了它的边框。这是突出问题的图片:

stupid IE8

可以在这里看到一个活生生的例子:http://rcnhca.org.uk/sites/first_steps/

按钮的标记是:

<a class="button alpha bold" href="#">
   <img alt="rcn icon" src="http://rcnhca.org.uk/sites/first_steps/wp-content/themes/megaamazing/library/images/rcn-icon.png">
</a>

还有 css(我使用滤镜来绘制渐变而不是图像):

a.button.alpha, a.button.alpha:focus {
    margin-left: 0px;
}

a.button.omega, a.button.omega:focus {
    margin-right: 0px;
}

a.button{
    display: block;
    position: relative;
    float: left;
    margin: 10px 5px;
    right: 0px;
    height: 2.438em;
    line-height: 2.438em;
    padding: 0 0.938em;
    border: #3a90a7 2px solid;
    font-size: 0.938em;
    text-decoration: none;
    color: #202d32;
    background: #ffffff;
    background: -moz-linear-gradient(top, #ffffff 0%, #e5e5e5 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5));
    background: -webkit-linear-gradient(top, #ffffff 0%,#e5e5e5 100%);
    background: -o-linear-gradient(top, #ffffff 0%,#e5e5e5 100%);
    background: -ms-linear-gradient(top, #ffffff 0%,#e5e5e5 100%);
    background: linear-gradient(top, #ffffff 0%,#e5e5e5 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 );
    border-radius: 5px; 
    -moz-border-radius: 5px; 
    -webkit-border-radius: 5px;
}

.oldie a.button{
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 );
}

a.button:hover {
    border: #202d32 solid 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 3px #FFFFFF inset;
    -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 3px #FFFFFF inset;
}

a.button:active{
    padding-top: 0.125em;
    padding-left: 1.063em;
    padding-right: 0.813em;
    height: 2.313em;
    background: #e5e5e5; /* Old browsers */
    /* IE9 SVG, needs conditional override of 'filter' to 'none' */
    background: #cccccc;
    background: -moz-linear-gradient(top, #cccccc 0%, #cccccc 3%, #e5e5e5 5%, #ffffff 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cccccc), color-stop(3%,#cccccc), color-stop(5%,#e5e5e5), color-stop(100%,#ffffff));
    background: -webkit-linear-gradient(top, #cccccc 0%,#cccccc 3%,#e5e5e5 5%,#ffffff 100%);
    background: -o-linear-gradient(top, #cccccc 0%,#cccccc 3%,#e5e5e5 5%,#ffffff 100%);
    background: -ms-linear-gradient(top, #cccccc 0%,#cccccc 3%,#e5e5e5 5%,#ffffff 100%);
    background: linear-gradient(top, #cccccc 0%,#cccccc 3%,#e5e5e5 5%,#ffffff 100%);
    -moz-box-shadow: 0 1px 2px #AAAAAA inset;
    box-shadow: 0 1px 2px #AAAAAA inset; 
}

.oldie a.button:active {
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#ffffff',GradientType=0 );
}

a.button img {
    position: relative;
    margin-right: 15px;
    vertical-align: middle;
}

有人知道这是怎么回事吗?谢谢。

最佳答案

我无法解释原因,但是当您移除 anchor 上的水平边距时,它就解决了问题(左侧和右侧)

我最好的猜测是 IE 过滤器正在做一些不可预测的事情。

如果您包装元素然后为其应用边距,应该可以解决问题。

关于HTML/CSS : IE8 background overflowing border,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10350228/

相关文章:

javascript - 使用 Javascript 删除 div

html - 如何使用 Bootstrap 在列之间添加空间

javascript - 视差 H1 和 H2

javascript - 在多个浏览器中附加事件

javascript - 为什么我非常标准的网站会破坏 IE?

javascript - 无法显示此 svg 图标

html - 正确的 HTML 结构

android - 移动横向模式下 div 高度 100%?

html - 将 div 的宽度设置为父级的父级宽度

css - 无论如何要删除 IE8 及以下版本中单击链接周围的边框?