how to override left:0 using CSS or Jquery?

CssCss Position

Css Problem Overview


I have an element, which has the following CSS:

.elem {
  left: 0;
  position: fixed;
  right: 0;
  width: 60%;
  z-index: 1000;
  }

The element does not span the whole screen. I would like it to "align" to the right hand side of the screen.

This would be easy, if I just removed left: 0, but I cannot tamper with the above CSS, so I need some CSS or Jquery to override, disable or remove the left:0 CSS.

Thanks for help!

Css Solutions


Solution 1 - Css

The default value for left is auto, so just set it to that and you will "reset" it.

.elem {
  left: auto;
}

Make sure that the above comes after the original CSS file.

Solution 2 - Css

Using CSS:

.elem {
    left: auto;
}

Using JQuery:

$(".elem").css("left", "auto");

Solution 3 - Css

Try auto property in CSS, which is equal to the default value.

Solution 4 - Css

With jquery:

$(".elem").css("left", "");

Solution 5 - Css

Whether this style you extracted is an external or an internal one, you can override it with an internal one such as:

.elem {
    position: fixed;
    right: 0;
    width: 60%;
    z-index: 1000;
  }

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
QuestionfrequentView Question on Stackoverflow
Solution 1 - CssJan HančičView Answer on Stackoverflow
Solution 2 - CssMohammad AniniView Answer on Stackoverflow
Solution 3 - CssDionView Answer on Stackoverflow
Solution 4 - CssAntonio BeamudView Answer on Stackoverflow
Solution 5 - CssDoğan AHMETCİView Answer on Stackoverflow