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%?

有帮助吗?

解决方案

Try with

node.style.maxWidth = '100%';

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top