Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > element.style.position="relative !important";

Reply
Thread Tools

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

 
 
petermichaux@gmail.com
Guest
Posts: n/a
 
      03-18-2006
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

 
Reply With Quote
 
 
 
 
petermichaux@gmail.com
Guest
Posts: n/a
 
      03-18-2006
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

 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      03-18-2006
On 18/03/2006 20:49, http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments