Question

I work on an Eclipse RCP application having a HTML editor using XULRunner. In the JavaScript code interacting with the editor, I want to set the maximum width of an element using CSSStyleDeclaration.maxWidth:

/* node is an HTMLImageElement */
node.style.maxWidth = "100%";

The code above fails with the following message

Warning: Error in parsing value for property 'max-width'.  Declaration dropped.

But if I use pixels, it works:

node.style.maxWidth = "100px";

What is the correct syntax to set the CSS max-width property to 100%?

Was it helpful?

Solution

Try with

node.style.maxWidth = '100%';

OTHER TIPS

I don't see any problems with the way you are declaring it. Your XULRunner must not be able to parse it properly.

Here are the official specs for max-width as written by MDN

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top