【问题标题】:Margin top isn't working in IE8 but works in all other browsersMargin top 在 IE8 中不起作用,但在所有其他浏览器中都起作用
【发布时间】:2014-06-03 19:26:05
【问题描述】:

我有一个按钮和一个放置在按钮上的箭头图像。编写 CSS 以便将箭头定位在按钮的右中心。该代码适用于 Chrome、Firefox 和 Safari。它在 IE9 和其他更高版本中也可以正常工作。但不适用于 IE8,我们的大多数客户都使用 IE8。 CSS 如下所示。

a.ui-priority-primary-inspire span.arr-right {
background: url("/cms/global/assets/images/site/icon_vsg/arr_right_7x11.png") no-repeat scroll right top hsla(0, 0%, 0%, 0);
display: block;
float: right;
height: 17px;
margin: -14px -9px 4px 79px;
overflow: hidden;
position: absolute;
width: 10px;
}

margin-top:-14px 适用于所有浏览器,但不适用于 IE。

【问题讨论】:

    标签: css internet-explorer-8 margin


    【解决方案1】:

    请改用padding-top。参考:http://reference.sitepoint.com/css/margin-top

    【讨论】:

      【解决方案2】:

      这称为 Negative Margin Bug 当您使用 position:absolute 时,您可以使用 top:-14px 而不是使用 negative margin 值。

      【讨论】:

      • 它再次产生相同的结果:(
      • 这实际上是一个复杂的应用程序。大约有 6 个不同的 css 文件放在一起。我想我不能在这里发布整个代码。
      猜你喜欢
      • 1970-01-01
      • 2019-11-27
      • 1970-01-01
      • 2013-06-10
      • 2014-08-13
      • 2019-08-20
      • 1970-01-01
      • 2011-05-03
      • 1970-01-01
      相关资源
      最近更新 更多