我正在创建一个 html 页面。因为我需要的是在一个位置设置动画的文本,它必须去固定在其他位置。这是我的代码
HTML:
<body>
<div id="text">Sample Text</div>
<script type="text/javascript">
$(document).ready(function() {
var textFxSettings = {
animation: 3,
color: "#111",
animationType: "in",
speed: 1000
};
jQuery.cjTextFx(textFxSettings); // INIT FUNCTION
jQuery.cjTextFx.animate("#text", {
onComplete: myFunction
});
});
</body>
CSS:
#text{
position:absolute;
top:230px;
left:530px;
font-size:24px;
}
.text_pos{
animation:spin 3s;
-moz-animation:spin 3s; /* Firefox */
-webkit-animation:spin 3s; /* Safari and Chrome */
-o-animation:spin 3s; /* Opera */
}
@-webkit-keyframes spin{
0% { -webkit-transform: translate(0px, 0px); }
100% { -webkit-transform: translate(0px, -150px); }
}
此翻译将转到正确的位置,但在 1 个循环后它会回到其原始位置(顶部:230)。我希望文本位于顶部:80。我尝试通过更改 text_pos 类的位置来尝试,但它不起作用。 谁能帮我解决这个问题。提前致谢。
最佳答案
你可以用来改变位置到div一样
$("#text").css({"top":"10px","left":"20px"});
关于jquery - 如何使用jquery在html中将div从一个位置更改为另一个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16036344/