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

P

petermichaux

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
 
P

petermichaux

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
 
M

Michael Winter

On 18/03/2006 20:49, (e-mail address 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top