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

CssWebkitCss Position

Css Problem Overview


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.

Css Solutions


Solution 1 - Css

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.

Solution 2 - Css

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarcusView Question on Stackoverflow
Solution 1 - CssthirtydotView Answer on Stackoverflow
Solution 2 - CssChris GodwinView Answer on Stackoverflow