Keep Group Focus on screen

Hey I have a group focus acting as a small menu/pop up when clicked on certain items on my site and it acts like a “more information” element. If the original item/element is low down the screen the group focus when clicked will sometimes appear half on half off the screen as it set to show below the group to reference.
Is there anyway we can ensure that when it is shown the whole element stays on the page? I.e. It may be set to show below the element but that would mean it would be half missing, I want it to responsively know it would be off the screen and therefore show higher up.