element.style.position="relative !important";

Discussion in 'Javascript' started by petermichaux@gmail.com, Mar 18, 2006.

  1. Guest

    Hi,

    I tried the following and everything worked fine.

    element.style.position="relative";

    Then I tried to make the CSS rule important and it didn't work. The
    positioning was all wrong in Safari and very jerky in Firefox.

    element.style.position="relative !important";

    Am I doing this correctly?

    Thanks,
    Peter
    , Mar 18, 2006
    #1
    1. Advertising

  2. Guest

    Hi,

    Still no good in Safari when the rule is inserted with !important. It
    is the same behavior as if I do not insert the rule at all: the
    positioning is all wrong. If the rule is defined in a stylesheet file
    then !important doesn't cause any problems.

    I was wrong, it is not jerky in Firefox. I had to restart firefox for
    other reasons and now it is ok. However, when I look in the DOM
    inspector the rule shows up as relative but not as important. If I
    hardcode the style into my HTML document in the element's style tag,
    then the Firefox DOM inspector shows that the rule is important. Hmmmm

    Is JavaScript support for inserting !important rules just not ready
    yet?

    Peter
    , Mar 18, 2006
    #2
    1. Advertising

  3. On 18/03/2006 20:49, wrote:

    [snip]

    > Then I tried to make the CSS rule important and it didn't work. [...]
    >
    > element.style.position="relative !important";
    >
    > Am I doing this correctly?


    No. The assigned string should only contain the declaration value.

    To set a priority, call the setProperty method, but this should not be
    necessary. In-line style declarations are the most specific possible,
    and will take precedence unless there is an !important declaration
    elsewhere.

    Mike

    --
    Michael Winter
    Prefix subject with [News] before replying by e-mail.
    Michael Winter, Mar 18, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luqman
    Replies:
    1
    Views:
    645
    Luqman
    Feb 7, 2006
  2. HANM
    Replies:
    2
    Views:
    693
    Joseph Kesselman
    Jan 29, 2008
  3. Konrad Hammerer
    Replies:
    14
    Views:
    593
    Jonathan N. Little
    Feb 7, 2008
  4. Ken Varn
    Replies:
    0
    Views:
    428
    Ken Varn
    Apr 26, 2004
  5. Amir Hardon
    Replies:
    0
    Views:
    251
    Amir Hardon
    May 31, 2004
Loading...

Share This Page