gpt4 book ai didi

javascript:如何使用 javascript 使文本旋转?

转载 作者:搜寻专家 更新时间:2023-10-31 08:25:21 26 4
gpt4 key购买 nike

<分区>

我有这个代码:

<img src="http://www.w3schools.com/html/html5.gif" id="imgid">
<h1 id='header'>Example</h1>
<!--This is an example html doc not the real thing!-->
<button onclick="spin(document.getElementById('header'));spin(document.getElementById('imgid'));">Spin!</button>
<script>
function spin(object) {
setInterval(function() {
object.style.transform += "rotate(10deg)";
}, 1);
}
</script>

如何使文本正确旋转?如果你能解释它是如何工作的,那就太好了。如果您需要我的来源的任何引用,那么:

我所说的“正确”是指旋转居中。 (不是整个页面)。

谢谢!

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com