CSS (webkit): overriding top with bottom on absolute-positioned element

≡放荡痞女 提交于 2020-04-05 07:30:13

问题


I'm having a problem with overriding some plugin CSS. Editing that CSS directly is not really an option, as it would make updating the plugin more risky.

The problem: an element has absolute positioning, and has top:0px in the original. I want to override it by bottom:0px.

For the sake of example

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

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

On firefox this works ok (bottom:0 is the applied style), but safari/chrome don't seem to be get over the top:0.

I can work around this problem, but it would be nice to come up with a clean solution.


回答1:


Use top: auto to "reset" top to its initial value.

bottom is a totally separate property to top (an element can have both a top and bottom), so perhaps you won't need bottom anymore.

Also, make sure your override selector is specific enough, but it doesn't sound like that's the problem in this case.




回答2:


.my .element { position: inherit !important; top: auto; }


来源:https://stackoverflow.com/questions/5078021/css-webkit-overriding-top-with-bottom-on-absolute-positioned-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!