how to override left:0 using CSS or Jquery?

后端 未结 5 1827
既然无缘
既然无缘 2021-02-01 00:22

I have an element, which has the following CSS:

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

The elemen

相关标签:
5条回答
  • 2021-02-01 00:33

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

    0 讨论(0)
  • 2021-02-01 00:37

    With jquery:

    $(".elem").css("left", "");
    
    0 讨论(0)
  • 2021-02-01 00:46

    Using CSS:

    .elem {
        left: auto;
    }
    

    Using JQuery:

    $(".elem").css("left", "auto");
    
    0 讨论(0)
  • 2021-02-01 00:47

    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.

    0 讨论(0)
  • 2021-02-01 00:50

    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;
      }
    
    0 讨论(0)
提交回复
热议问题