0

I have a javascript file containing css :

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?

Mark Bell
  • 28,985
  • 26
  • 118
  • 145
user3328513
  • 189
  • 1
  • 3
  • 12

1 Answers1

0
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?
  • Look for the file/plugin that overrides the values - you should always do this rather than just putting an !important there
Bram Vanroy
  • 27,032
  • 24
  • 137
  • 239
  • 2
    @user3328513 See my edit. Also `1e7` doesn't seem to me to be a valid value. – Bram Vanroy Apr 03 '14 at 08:34
  • If this didnt work, use inspector in chrome (F12) or right click the element and select Inspect Element. ON the right hand column, you will see all the CSS styles applied... – Dean Meehan Apr 03 '14 at 08:43
  • 1
    @Bram Vanroy: JavaScript number literals can be specified in scientific notation, so `1e7` is `10000000`. (At least in Firefox it works anyway.) – BoltClock Apr 03 '14 at 08:48
  • @BoltClock Thanks, I wasn't aware of that. (Quite a high value though...) – Bram Vanroy Apr 03 '14 at 21:42