多重定位,随机大小,绝对定位的元素,使他们不重叠

编程入门 行业动态 更新时间:2024-10-24 16:24:35
本文介绍了多重定位,随机大小,绝对定位的元素,使他们不重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

确定我需要能够定位一堆随机大小的绝对定位词的页面上,但我不希望任何元素重叠。

我们的最终目标是拥有一个流体词云来响应用户交互(记住,球谷歌涂鸦?)。我真的想从头开始构建这个发展我的这种发展的认识。在这个部门的帮助也将是AP preciated:)

The end goal is to have a fluid word cloud that responds to user interaction (remember the Google Balls Doodle?). I would really like to build this from scratch to develop my understanding of this type of development. Any help in this department would also be appreciated :)

推荐答案

我不知道,如果你也想随机放置一个容器内的话,但我已经写了小提琴的做到了这一点。您可以修改code之后对方就一个字的位置,如果你想虽然。我觉得关键部分是检查是否有碰撞的方法。

I'm not sure if you also want to position the words randomly inside a container, but i've written a fiddle that does just that. You can modify the code to position one word right after the other if you want to though. I think the key part is the method to check if there's a collision.

请参见 jsfiddle/fZtdt/13/

编辑:请注意,这是非常简单,没有优化code。例如,如果你会增加很多的话,很可能是该脚本将不能够满足所有单词的容器内,并进入死循环。

Be aware that this is very simple and unoptimized code. If for example you would add to many words, chances are that the script won't be able to fit all words inside the container, and get into an endless loop.

更多推荐

多重定位,随机大小,绝对定位的元素,使他们不重叠

本文发布于:2023-10-08 02:54:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471300.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:使他   元素   大小

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!