如何检测使用 javascript 的换行? [英] How can I detect wrapping with javascript?

查看:35
本文介绍了如何检测使用 javascript 的换行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在动态宽度 div 中加载了固定宽度的 div.固定的 div 都彼此相邻并最终环绕.我想要的是检测一个 div 是否以它自己的方式结束.我能想到的唯一方法是检测 div 包裹的位置,但我无法弄清楚如何.非常感谢您的帮助.

I have a load of fixed width divs inside a dynamic width div. The fixed divs all go next to each other and eventually wrap. What I want is to detect if one div ends up on a line on it's own. The only way I can think of for doing this is detecting where the divs wrap but I haven't been able to figure out how. Help is really appreciated.

推荐答案

所以你想知道 div 是否在它自己的行上?

so you want to know if the div is on it's own row?

您可以检查每个 div 的 offsetTop 以检查其他 div 是否打开同一行.如果 div 的 offsetTop 与其他任何一个都不匹配,那么它就靠它自己了.

you can check each div's offsetTop to check against the other div's if they are on the same row. if the div's offsetTop dont match any of the others, then it's on it's own.

这篇关于如何检测使用 javascript 的换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆