为什么我的 position: absolute div 在 Edge 中的位置不同?

Why is my position: absolute div placed differently in Edge?

我们正在尝试在图片的一角添加徽章。为此,我们使用父级 <div> 作为包装器,并在内部使用 <span>。到目前为止,它在 Chrome、Firefox 和 IE11 上工作正常,但在 MS Edge 中它没有按预期工作。看起来 Edge 计算出的 right: 属性 与其他人非常不同。

结果符合预期:

意外结果:

这是我的代码:

.parent {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  position: relative;
  overflow: hidden;
}

.child {
  background-color: #e2001a;
  position: absolute;
  right: -65px;
  width: 220px;
  height: 50px;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  padding-left: 100px;
  display: table;
  z-index: 10;
  color: white;
  text-align: center;
  line-height: 1.2;
}
<div class="parent">
  <span class="child">Some cool text</span>
</div>

是我做错了什么,还是 Edge 的行为与其他浏览器有很大不同?

你可以像下面那样做不同的事情,它在 Edge 上似乎没问题*

.parent {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  position: relative;
  overflow: hidden;
}

.child {
  background-color: #e2001a;
  position: absolute;
  top: 0;
  left: -20px;
  right: -20px;
  height: 50px;
  text-align: center;
  transform: translateX(30%) rotate(45deg) translateY(70%);
  z-index: 10;
  color: white;
  text-align: center;
  line-height: 1.2;
}
<div class="parent">
  <span class="child">Some cool text</span>
</div>

* 不知道为什么...

更新以使用原始代码片段:

transform 需要像上面那样更改,translateX()translateY() 需要一些调整才能工作。

这是在 Chrome、Firefox、Edge 和 IE11 中工作的代码:

.parent {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  position: relative;
  overflow: hidden;
}

.child {
  background-color: #e2001a;
  position: absolute;
  right: -65px;
  width: 220px;
  height: 50px;
  transform: translateX(10%) rotate(45deg) translateY(100%); //wokring with translateX and translateY instead of just rotate
  display: table;
  z-index: 10;
  color: white;
  text-align: center;
  line-height: 1.2;
}
<div class="parent">
  <span class="child">Some cool text</span>
</div>