Firefox 中的 HTML 元素位置不同

标签 html css

这是我的 design .底部的右箭头在 chrome 和 IE 中看起来不错。但在 Firefox 中它的位置不同。

 #prev{
    background-image: url("http://oi57.tinypic.com/2ztfrx4.jpg");
    background-repeat: no-repeat;;
  }       

  #next{
    background-image: url("http://oi60.tinypic.com/2wpjazt.jpg");
    background-repeat: no-repeat;;
  }

Please check the attached image .

我附上了在 Firefox 中运行的图像,右箭头位置向下。

我该如何解决这个问题?

最佳答案

您可以在 #next 上使用负边距来解决对齐问题,如下所示。

由于您为图标图像/元素指定了宽度,只需将左边距设置为宽度的负值,在本例中为 -26px。

此解决方案适用于最新版本的 Firefox、Chrome 和 IE。

#prev {
    background-image: url("http://oi57.tinypic.com/2ztfrx4.jpg");
    background-repeat: no-repeat;
    display:inline-block;
    width:26px;
    height:26px;
}
#next {
    background-image: url("http://oi60.tinypic.com/2wpjazt.jpg");
    background-repeat: no-repeat;
    display:inline-block;
    width:26px;
    height:26px;
    float: right;
    margin-left: -26px;
}
.products {
    border-style: solid;
    border-width: 1px;
    border-color: #98bf21;
    text-align:center;
    white-space:normal;
}
<div id="container">
    <div id="catalog" style="width:300px;height:557px;">
        <div id="logo">
            <img alt="Mountain View" src="http://files.usmre.com/4215/mountain%20view%20lake.jpg" style="width:300px;height:200px;">
        </div>
        <div class="products" id="productTitle" style="width:296px;height:350px; font-size: 24px;"></div>
    </div>
    <div style="position:relative;display:block;padding:0px;margin:0px;white-space:nowrap;width:300px;padding-top:10px">
        <div id="prev"></div>
        <div id="next"></div>
    </div>
</div>

关于Firefox 中的 HTML 元素位置不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31444300/

相关文章:

php - 将元素固定在中心但启用滚动

jquery - 我想为每个必需的标签添加 required(*)

html - 如何判断是什么导致 Internet Explorer 发出安全警告

javascript - 创建导航菜单,一个导航项高于容器的高度

javascript - 使每隔几秒创建的生成的 div 落在屏幕上

html - 试图使边界曲线向内

php - Joomla 模块在文章中可见但在类别中不可见

html - 对齐 flexbox 中的内容在 IE 11 中不起作用

html - 在表格中用 css 包装单词

javascript - 在 javascript/html 中取消关注选项卡上的静音选项卡音频