【问题标题】:Firefox absolute position is positioning outside of parent container and in the middle of the screenFirefox 绝对位置定位在父容器之外和屏幕中间
【发布时间】:2013-11-19 13:02:10
【问题描述】:

这很奇怪,但 IE8 目前处理我的布局比 FF 更好。使用 Firefox,每个绝对定位元素都以页面中间为中心,而不是以它的父级为中心,你有哪些类 position:absolute;和位置:相对; - 这发生在我的布局上的几件事上。该布局在 Chrome/IE8+ 中完美运行。

任何已知的修复或任何类似的问题?

谢谢。

【问题讨论】:

  • 请在您的帖子中分享一些代码,并在fiddle 表示感谢。

标签: html css firefox


【解决方案1】:

确保父元素有

position: relative

这是fiddle

#red{
  width:200px;
  height:200px;
  background: red;
  position: relative;
}
#blue{
  width:100px;
  height:100px;
  background: blue;
  position: absolute;
  left: 50%;
  margin-left: -50px;
}

<div id="red">
  <div id="blue"></div>
</div>

【讨论】:

  • 嘿伙计,谢谢。不幸的是,我已经正确分类了父元素。这是我以前从未遇到过的问题。
猜你喜欢
  • 1970-01-01
  • 2014-12-27
  • 1970-01-01
  • 2018-08-06
  • 2021-12-31
  • 1970-01-01
  • 2016-07-09
  • 1970-01-01
  • 2012-08-23
相关资源
最近更新 更多