html - 包含在链接中的图像仅在 Firefox 中被另一个 float 链接重叠,Chrome 和 IE 都可以

标签 html css positioning

我有一个导航栏,它在调整页面大小时按比例缩放其大小:

HTML:

<div class="wrap">
    <div id="breadcrumbs">
        <div class="breadcrumbs-insert">
            <a href="#"><img src=
            "http://i.imgur.com/1gLVM1T.png"></a>
            <a href="#">Text 1</a>
            <span>Text 2</span>
        </div>
    </div>
</div>

和 CSS:

#breadcrumbs {
        position: relative;
        width: 100%;
        height: 0;
        padding-bottom: 2.5%;
        letter-spacing: 1px;
        font-size: 0.35em;
        font-family: 'HelveticaNeue-Light', "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
        background: #0073b5;
        color: #ffffff;
    }

    .breadcrumbs-insert {
        position: absolute;
        width: 100%;
        height: 100%;
    }

    #breadcrumbs span {
        line-height: 100%;
        height: 72%;
        padding-top: 0.7%;
        float: left;
        display: block;
        padding-right: 2.08333%;
        padding-left: 2.08333%;
        background: #39a9d1;
        color: #ffffff;
        text-decoration: none;
    }

    #breadcrumbs a {
        line-height: 100%;
        height: 72%;
        padding-top: 0.7%;
        float: left;
        display: block;
        padding-right: 1.04166%;
        padding-left: 1.04166%;
        color: #ffffff;
        text-decoration: none;

    }

    #breadcrumbs img {
        height: 100%;
    }

    #breadcrumbs a:hover, a:active, a:visited {
        color: #ffffff;
        text-decoration: none;
        background: #39a9d1;
    }

    #breadcrumbs a:hover, a:active {
        background: #39a9d1;
    }

    #breadcrumbs a:first-of-type {
        margin-left: 1.04166%;
        padding-left: 0.26041%;
        padding-right: 0.26041%;
        height: 100%;
        padding-top: 0;
    }

    #breadcrumbs a:last-of-type {
        padding-right: 2.08333%;
    }

这是 fiddle https://jsfiddle.net

出于某种原因,在 Firefox 中,环绕图像的第一个链接与下一个 float 链接重叠。 Chrome 和 IE 运行良好。

几个小时以来一直在努力解决这个问题,最后放弃了......

最佳答案

您可以使用无序列表代替导航。

html:

<ul>
  <li><a href="url">text 1</a></li>
  <li><a href="url">text 2</a></li>
</ul>

CSS:

  ul li { 
  display: inline; 
  list-style-type: none;
  }

不确定这是否是您要尝试执行的操作,但在您的示例中这对我来说已经解决了问题。

关于html - 包含在链接中的图像仅在 Firefox 中被另一个 float 链接重叠,Chrome 和 IE 都可以,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36488000/

相关文章:

javascript - 如何从用户输入的可编辑 <td> 中获取文本?

javascript - 我的将单词包裹在跨度中的算法的缺陷在哪里?

css - 悬停时旋转元素时的奇怪行为

html - 调整大小时图像之间的 Chrome 1px 间隙

html - 跨平台垂直对齐 Section 中的内容

html - 当窗口太小时,文本消失

html - 相对于 div 的动态搜索栏

javascript - Jquery 将自定义选项卡移动到下一个

html - 使用 css 伪元素的绝对/相对定位

html - 在 div 顶部居中图像