问题
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:
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.
来源:https://stackoverflow.com/questions/9838202/how-can-i-detect-wrapping-with-javascript