I’ve looked at UIkit, and some other jQuery Context Menu Plugin’s but they all tend to behave like this:

As you can see actual div with menu renders outside the window and so valuable content is not visible.
Is there any way to make a pop up div (say div has id menu) auto stick to right border on its own when there is not enough space using jQuery (meaning when it does not fit into current window borders move itself left so that it would appear where needed) like that:

I tend to use this plugin . It will auto-adjust the position to always stay in the viewport