html - Internet Explorer 降低元素内具有奇数高度的文本

标签 html css internet-explorer

我有这个元素:

.container {
  font-size: 14px;
  line-height: 20px;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.link {
  color: #3072c4;
  cursor: pointer;
}

.counter {
    display: inline-block;
    min-width: 9px;
    padding: 0 4px;
    text-align: center;
    line-height: 17px;
    background: #FF8000;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 17px;
}
<span class="container">
		<span class="link">
      Feedback
    </span>
      <span class="counter">166</span>
	</span>

它的高度必须是 17px,水平填充应该是 4px,字体大小应该是 12px。它看起来像是 Chrome 和 Firefox 中的原型(prototype):

enter image description here

但是在 Internet Explorer 中有一个问题:

enter image description here

它降低了里面的文本,它没有很好地垂直对齐。如果我将元素的行高和宽度设置为 18px(以及所有其他偶数值),一切正常,但我需要 17px。如何避免在 IE 中降低文本?

最佳答案

您可以为 IE 添加特定的样式。你可以试试这个:

.container {
      font-size: 14px;
      line-height: 20px;
      font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    }

    .link {
      color: #3072c4;
      cursor: pointer;
    }

    .counter {
        display: inline-block;
        min-width: 9px;
        padding: 0 4px;
        text-align: center;
        line-height: 17px;
        background: #FF8000;
        color: #fff;
        font-size: 12px;
        font-weight: 700;
        border-radius: 17px;
    }
    @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
      /* IE Edge 12+ CSS styles go here */ 	
      .counter {
          display: inline-block;
          min-width: 9px;
          padding: 0px 4px 1px 4px;
          text-align: center;
          line-height: 17px;
          background: #FF8000;
          color: #fff;
          font-size: 12px;
          font-weight: 700;
          border-radius: 17px;
        }
    }
<span class="container">
		<span class="link">
      Feedback
    </span>
      <span class="counter">166</span>
	</span>

关于html - Internet Explorer 降低元素内具有奇数高度的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47634694/

相关文章:

javascript - 函数完成后jQuery隐藏div

javascript - 每次在 jquery 中单击按钮时如何使输入添加值?

javascript - 检测浏览器并显示其他内容

javascript - HTML - 搜索不起作用

javascript - CSS Accordion 菜单按钮

html - 为什么 CSS 子菜单在 Internet Explorer 上失败?

html - 打印时 Ng-show 被忽略?

javascript - 仅隐藏那些为空或没有文本的跨度

html - 如何摆脱 'subscribe to our newsletter' 部分上方的空白

perl - IE9 丢失对本地 Catalyst 服务器的请求