Gwt 修改css动画属性?
有没有办法通过编程定义和启动css动画?我想制作一个从一个绝对位置到另一个绝对位置的div动画。比如:Gwt 修改css动画属性?,gwt,Gwt,有没有办法通过编程定义和启动css动画?我想制作一个从一个绝对位置到另一个绝对位置的div动画。比如: FlowPanel fp = new FlowPanel(); fp.getElement().getStyle().setPosition(Position.ABSOLUTE); fp.getElement().getStyle().setLeft(50, Style.Unit.PX); fp.getElement().getStyle().setTop(50, Style.Unit.PX)
FlowPanel fp = new FlowPanel();
fp.getElement().getStyle().setPosition(Position.ABSOLUTE);
fp.getElement().getStyle().setLeft(50, Style.Unit.PX);
fp.getElement().getStyle().setTop(50, Style.Unit.PX);
...
// something like:
fp.setAnimation("top: 300px");
我看到我们可以在css文件中定义css动画,更改div样式的名称将触发动画。但我不知道我们是否可以通过编程修改css中定义的动画。例如:
// css file
.testAnimation {
top: 500px;
transition-property: top;
transition-duration: 1s;
}
...
// But we can't modify the "top" attribute here depending on runtime needs?:
fp.setStyleName("testAnimation"); // I may want "top" to be some other value here.
谢谢您可以使用
getElement().getStyle().setProperty(property,value)
设置任何css属性。但这不是正确的做法。建议的方法是通过css
这可能会帮助您您有几种方法 1) GWT动画- 2) Jquery方法-通过GWTQuery-
3) GWT中的JSNI-这与您是否可以更新您选择的方法以及为什么相关?