CSS(webkit):在绝对定位元素上覆盖顶部与底部

时间:2011-02-22 12:19:57

标签: css webkit css-position

我在覆盖某些插件CSS方面遇到了问题。直接编辑CSS实际上不是一个选项,因为它会使更新插件更具风险。

问题:元素具有绝对定位,并且在原始元素中具有顶部:0px。我想通过底部覆盖它:0px。

为了举例

    .element {position:absolute; top:0;}

    /* in another file */
    .my .element {bottom:0;}

在firefox上运行正常(底部:0是应用的样式),但是safari / chrome似乎没有超过顶部:0。

我可以解决这个问题,但提出一个干净的解决方案会很好。

2 个答案:

答案 0 :(得分:182)

使用top: autotop重置为initial value

bottom是与topan element can have both a top and bottom)完全独立的属性,因此您可能不再需要bottom

另外,请确保您的覆盖选择器为specific enough,但在这种情况下听起来不是问题。

答案 1 :(得分:5)

.my .element { position: inherit !important; top: auto; }
相关问题