在table-cell中的position on :: after在Firefox中不起作用? [英] Position on ::after in table-cell doesn't work in Firefox?

查看:178
本文介绍了在table-cell中的position on :: after在Firefox中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码应创建一个伪元素,其跨越其父元素宽度的100%。但是这不会在Firefox中工作,它在Chrome中工作。 Firefox似乎忽略了 .parent position:relative 。这是一个错误吗?

The following code should create a pseudo-element which spans 100% of its parent element's width. However this won't work in Firefox, it does work in Chrome. Firefox seems to ignore the .parent's position:relative. Is this a bug?

HTML

<div class="parent">

</div>

CSS

.parent{
  background:red;
  width:100px;
  height:100px;
  position:relative;
  display:table-cell;
}

.parent:after{
left:0;
  content:'';
  right:0;
  top:10px;
  height:20px;
  background:green;
  position:absolute;
}

演示

chrome 中查看此图片

See this images in chrome

现在在 firefox

and now see this result in firefox

推荐答案

如果可能,更改 display:table-cell inline-block 来修复此错误。或者,将父项上的 position:relative 更改为 absolute

If possible, change the display:table-cell to block or inline-block to fix this error. Alternatively, change position:relative on the parent to absolute.

这篇关于在table-cell中的position on :: after在Firefox中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆