X和Y变换期间的DIV高度大小
js
setInterval(() => {
let d = new Date();
let sec = d.getSeconds();
let min = d.getMinutes();
let hrs = d.getHours();
const hourRotation = 30 * hrs + min / 2;
const minRotation = 6 * min;
const secondRotation = 6 * sec;
hours.style.transform = `rotate(${hourRotation}deg)`
minutes.style.transform = `rotate(${minRotation}deg)`
seconds.style.transform = `rotate3d(.5, .005, .6, ${secondRotation}deg)`
}, 1000)
new Date().getMinutes();
new Date().getSeconds();
    我有一个不直接面对用户的时钟面图像,它的成角度为45度。我希望时钟可以根据时钟面的位置来稍微调节其高度。为了光学幻觉。
    当我按原样使用代码时,我会稍微获得所需的效果,但是时钟手在时钟左右较薄,而秒针也不会完全扩展12 o时钟和6 o时钟位置....
通过更多地控制结果,这是什么方法?
JS
setInterval(() => {
let d = new Date();
let sec = d.getSeconds();
let min = d.getMinutes();
let hrs = d.getHours();
const hourRotation = 30 * hrs + min / 2;
const minRotation = 6 * min;
const secondRotation = 6 * sec;
hours.style.transform = `rotate(${hourRotation}deg)`
minutes.style.transform = `rotate(${minRotation}deg)`
seconds.style.transform = `rotate3d(.5, .005, .6, ${secondRotation}deg)`
}, 1000)
new Date().getMinutes();
new Date().getSeconds();
I have a clock face image that is not directly facing the user, it is angled 45 degrees. I want the clock Hands to slightly adjust their height depending on where on the clock face they are. For the sake of optical illusion.
When I use the code as is, I slightly get the desired effect, but the clock hand gets thinner at around 5-8 mark on the clock, and the seconds hand does not get fully extended at the 12 o clock and 6 o clock position....
What is another way to do this with more control over the outcome?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CSS可以在3D中工作,因此,如果您旋转时钟面,则手将自动调整其高度和宽度。
这是一个简单的例子。片段使旋转角度80而不是45度,以便您可以清楚地看到手正在根据其位置进行调整。
显然,您需要考虑希望观察者与整个场景相关的位置,而不仅仅是与时钟相关的位置。因此,将需要研究视角 - 原始位置。
CSS can work in 3d so if you rotate your clockface the hands will automatically adjust their height and width.
Here's a simple example. The snippet makes the angle of rotation 80 rather than 45 degrees just so you can see clearly that the hands are adjusting depending on their position.
You will obviously need to think about where you want the observer to be positioned in relation to your whole scene rather than just in relation to the clock. So perspective-origin and position will need looking into.