How to wrap an element if it goes beyond the width?
There is a tournament grid, it can be from 1 to 7 stages.
When you click on i, a match opens an element in which all games in this mast and infa are indicated, by default it opens to the right of i. In cases when the table is more than 4 stages, the window with information goes beyond the element where the grid lies.
Tell me how you can determine in this case that the window goes beyond the frame in order to move it to the left in the future. I'm not interested in a specific solution, but in a method / method. We need a transfer, we are not interested in other options.
To place the code, please use CodePen or similar tool. Thanks you!