I make a div and on mouse hover, on that div, I show another div and give the position of div at the right side of parent div but when parent div reaches right corner of the screen then some part of popup div hide inside the window screen. So, I want that to move the popup div automatically left, top, bottom where that popup div shows properly.
I attached a image for showing that what is the problem I get and I want to move left that popup div when this type of condition come.
Show us your code. We cannot troubleshoot a picture.
<copied from previous post>
Please give the full code in a “working page” or a CodePen so we can see what you see.
A “working page” is one that starts with <!doctype html>, contains <head> and <body> sections, and ends with </html>
If you include code in your post, be sure to preceed the block of code with three backticks on a line by themselves and ends with another three backticks on a line by themselves, like this
```
your code here
```
Alternatively, you can highlight your code and click the </> symbol in the editor’s menu bar.
Have you tested for this problem in any other browsers?
I am not able to send you code because it is coming dynamically. I send you the website link you can check there what is the problem.
the link is “http://www.pfyidev.apikdd.com/” go to Electronics section and mouse hover on the ratings and then the popup open.
I can’t help with a js solution as that is too complicated for me but I can offer an alternative css compromise.
If instead of moving the box to the right or left you simply display the box above the element then you will never need to worry about it being cut off.
If you add this code to the end of the css files for testing you can see the effect. If you don’t like it just remove the code and hope that someone posts a js solution (although I think that would be quite involved).
Thanks for a solution but I already told to the client about this solution but he doesn’t want this. He wants to move the popup div left automatically when there is no space for the popup.
I want to move the popup div left automatically when there is no space for the popup.
I just save the page and attached a zip file so you can use this and implement the js code but I am not able to upload the file. It shows that new user cannot upload files.
So, if you want the file so please save the page and work on this problem. JS code is written in the common.js file ( only first 2 line for popup show and hide ).
Hey @PaulOB, not much to tidy there, though. :-) I just noticed you accidentally declared tot1 and tot2 twice… oh and one small thing, .getBoundingClientRect() also returns a property right, which would save you adding the width.
However, @Praveen_Kumar_Verma you could improve this quite a bit if you would ditch all that inline JS and add a proper event listener add the end of the body; e.g. you could cache the carousel’s bounding client rect, and the hovered element would be readily available as this, which saves you a couple of DOM queries… like