如何获得2个元素之间的距离(中间点)?

编程入门 行业动态 更新时间:2024-10-27 15:22:41
本文介绍了如何获得2个元素之间的距离(中间点)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要你的帮助!我在它们之间放置了随机数量的div。

i need your help! I have a random amount of divs placed between themselves.

<div id="items"> <div class="item">Item description</div> <div class="item">Item description</div> <div class="item">Item description</div> <div class="item">Item description</div> </div>

每个都有不同的高度,我必须计算它们之间的距离。距离每个项目的每个中间点非常重要。

Each of the has a different height and i have to calculate the distance between them. It is really important that the distance is from each middle point of each item.

提前致谢!

也许我的形象会比我糟糕的英语更好地解释:)

Maybe my image will it explain better than my horrible english :)

推荐答案

哦,天哪!有时它比你想象的要容易!

Oh my gosh! Sometimes it is easier than you might think!

var currentCenterPoint = $('.current').outerHeight() / 2; var nextCenterPoint = $('.current').next().outerHeight() / 2; var amount = (currentCenterPoint + nextCenterPoint);

更多推荐

如何获得2个元素之间的距离(中间点)?

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

发布评论

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

>www.elefans.com

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