开发者

YUI3 (JS) setStyle using vendor prefixes

How do I use YUI3's set style to set something like -webkit-border-radius: 10px;?

e开发者_运维知识库xample:

Y.one('#mydiv').setStyle('-webkit-border-radius', '10');


Use camel case. When DOM scripting, style properties should always be set using camelCase. Webkit is lax about that and violates spec.

Y.one('#mydiv').getDOMNode().style.setProperty('mozBorderRadius', '10');

For border-radius, it's pretty safe (these days) to skip the vendor prefix, though.

Source


In case anyone else still needs to accomplish this, here's how I did it:

Y.one('#mydiv').getDOMNode().style.setProperty('-moz-border-radius', '10');


Should work.

I think you are missing the 'px' for

Y.one('#mydiv').setStyle('-webkit-border-radius', '10');

Should be

Y.one('#mydiv').setStyle('-webkit-border-radius', '10px');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜