How can I detect wrapping with javascript? [closed

2019-07-31 14:31发布

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.

1条回答
来,给爷笑一个
2楼-- · 2019-07-31 14:56

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

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.

查看更多
登录 后发表回答