如何使用 CSS 或 Jquery 覆盖 left:0?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10102915/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to override left:0 using CSS or Jquery?
提问by frequent
I have an element, which has the following CSS:
我有一个元素,它具有以下 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:0CSS.
这很容易,如果我只是删除left: 0,但我不能篡改上面的 CSS,所以我需要一些 CSS 或 Jquery 来覆盖、禁用或删除left:0CSS。
Thanks for help!
感谢帮助!
回答by Jan Han?i?
The default value for left
is auto
, so just set it to that and you will "reset" it.
为默认值left
是auto
,因此只需将它设置为你将“重置”了。
.elem {
left: auto;
}
Make sure that the above comes after the original CSS file.
确保以上内容出现在原始 CSS 文件之后。
回答by Mohammad Anini
Using CSS:
使用 CSS:
.elem {
left: auto;
}
Using JQuery:
使用 JQuery:
$(".elem").css("left", "auto");
回答by Dion
Try auto
property in CSS, which is equal to the default value.
auto
在 CSS 中尝试属性,它等于默认值。
回答by Antonio Beamud
With jquery:
使用 jquery:
$(".elem").css("left", "");
回答by Do?an AHMETC?
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;
}