简体   繁体   English

!重要的JavaScript CSS会去哪里

[英]!important javascript css where would it go

I have a javascript file containing css : 我有一个包含css的javascript文件:

a(this).css({
    position:"fixed",
    top: "210px",
    left: "1450px" ,
    width: "30px", 
    height: "30px", 
    margin: "0", 
    padding: "0", 
    minWidth: "65px", 
    listStyleType: "none", 
    zIndex: 1e7
});

The top and left seems to get changed somewhere else when I resize the screen. 调整屏幕大小时,顶部和左侧似乎在其他地方发生了变化。 Where to I add !important to them to see if that works? 我在哪里添加!important对他们来说是否有效?

a(this).css({
    "position": "fixed",
    "top": "210px !important",
    "left": "1450px !important",
    "width": "30px",
    "height": "30px",
    "margin": "0",
    "padding": "0",
    "minWidth": "65px",
    "listStyleType": "none",
    "zIndex": 1e7
});

But if you are changing so many values, I advise you to use a class instead. 但是,如果要更改许多值,我建议您改用一个类。 If the above doesn't work: 如果上述方法不起作用:

  • Are you sure a(this) refers to the right element? 您确定a(this)指向正确的元素吗?
  • Look for the file/plugin that overrides the values - you should always do this rather than just putting an !important there 寻找覆盖值的文件/插件-您应该始终这样做,而不是在其中放置!important

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM