简体   繁体   English

如何在画布中使用滚轮移动文本

[英]How to move text with the wheel in the canvas

I now want to place text on the spikes inside the wheel and I need them to rotate the with the wheel as well.我现在想在轮子内的尖刺上放置文字,我也需要它们与轮子一起旋转。 Also these number of spikes can change.I am unable to do this as I am just starting with html.这些峰值的数量也可以改变。我无法做到这一点,因为我刚开始使用 html。 The part where I am having trouble is how to detect the number of spikes in the wheel dynamically.And how to place the p tags dynamically over spikes and then move them with the wheel?我遇到麻烦的部分是如何动态检测轮子中的尖峰数量。如何将p标签动态放置在尖峰上,然后随轮子移动它们?

Can someone please help me out here?有人可以帮我吗?

As discussion in comments作为评论中的讨论

Posted my answer with pure CSS用纯 CSS 发布我的答案

 body { text-align: center; padding: 100px 0 0 0; color: #fff; background: #1d1f20; } .wheel { width:255px; height:255px; margin: 0 auto; position: relative; -webkit-animation: rotation 4s infinite linear; } @-webkit-keyframes rotation { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(359deg); } } .wheel span{ position: absolute; } span.fir { top: 45px; left: 122px; } span.sec { top: 75px; right: 62px; transform: rotate(45deg); } span.thi { top: 135px; right: 51px; transform: rotate(101deg); } span.frt { top: 190px; right: 92px; transform: rotate(-230deg); } span.fiv { top: 190px; left: 92px; transform: rotate(-136deg); } span.six { top: 135px; left: 51px; transform: rotate(-111deg); } span.svn { top: 75px; left: 62px; transform: rotate(-52deg); }
 <div class="wheel" > <img src="https://cdn.iconscout.com/icon/premium/png-256-thumb/car-wheel-2-827505.png"> <span class="fir">hi</span> <span class="sec">hi</span> <span class="thi">hi</span> <span class="frt">hi</span> <span class="fiv">hi</span> <span class="six">hi</span> <span class="svn">hi</span> </div>

You can change image and then change values its as per view您可以更改图像,然后根据视图更改值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM