html - 使用 rowspan 在表中奇怪的 IE 位置绝对居中

标签 html css internet-explorer

我在使用 rowspan 时在 InternetExplorer 上将表格中的元素居中时遇到问题。 enter image description here

我使用位置绝对前 50%,变换:translateY(-50%) 到中心。但结果很奇怪。这只发生在 rowspan 的 IE 上。知道为什么以及如何解决它吗?

th, td {
  position: relative;
  border: 1px solid red;
  padding: 0 25px;
}

.sortable {
  background-image:url('https://imageog.flaticon.com/icons/png/512/25/25243.png?size=1200x630f&pad=10,10,10,10&ext=png&bg=FFFFFFFF');
  background-size: contain;
  background-repeat: no-repeat;
  display: inline-block;
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  height: 10px;
  width: 10px;
}
<table>
  <tr>
    <th rowspan=2>
      first
      <span class="sortable"></span>
    </th>
    <th rowspan=2>second</th>
    <th colspan=2>first</th>
  </tr>
  <tr>
    <th>one</th>
    <th>two</th>
  </tr>
</table>

最佳答案

你的代码在 IE 10.0 上与我一起工作,检查你的 IE 版本,因为 transform CSS 属性开始被 IE 9.0 支持使用 -ms- 前缀。 W3Schools Ref

enter image description here

关于html - 使用 rowspan 在表中奇怪的 IE 位置绝对居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47939641/

相关文章:

html - border-collapse 在 chrome 和 firefox 中的工作方式不同

CSS 未正确加载

html - 按 F5 后 IE 不再评估元刷新

html - 是否可以修复长 html huxtable 的头部?

javascript - 如何通过 jQuery 中元素的索引设置数据属性值?

python - 从 Flask 中的文本区域检索文本

html - 无法更改图像的不透明度

javascript - 如何在内容展开时更改 <div> 高度?

css - 浏览器不支持 Bootstrap 中的字体

jquery - 使用 jquery 动画时 IE 中的样式问题