2013-02-17 35 views
0

一个DIV或SPAN的宽度,我曾尝试这样做,但出成功(所有这些东西是jQuery中那么容易。arrrrr !!!)动画在道场

我曾尝试以下(和各种排列)但没有成功:

<body> 
<span id="responseMsg" style="width:250px">Hi There</span> 
</body> 

JS:

dojo.animateProperty({ 
    node: dojo.byId("responseMsg"), duration: 1000, 
    properties: { 
     backgroundColor: { start: "white", end: "#66CC00" } 
    } 
}).play(); 
dojo.animateProperty({ 
    node: dojo.byId("responseMsg"), duration: 1000, 
    properties: { 
     width: 0 
    } 
}).play(); 

我已经摆弄起来here所以你可以看到我的意思。 (我猜dojo动画CSS属性不是变量)

回答

1

给你的span-element一个块级布局,它应该工作。

<span id="responseMsg" style="width:250px;display:block;">Hi There</span> 

顺便说一句,inline-css很难维护。

您更新的提琴:http://jsfiddle.net/VfEye/1/

+0

运行完美。添加'white-space:nowrap;'并且文本在合同时不会折叠。你知道为什么文本在div之外是可见的吗? – Sevenearths 2013-02-17 13:17:40

+0

是的,只需在您的CSS规则中添加“overflow:hidden”,并在调整大小时剪切文本。 – Raoul 2013-02-17 13:19:45

+0

完美!非常感谢 – Sevenearths 2013-02-17 13:31:45