I have a fixed position div that I want to center in my browser window.
Although it can be done with CSS, the issue is that I am dynamically changing the element's width multiple times (due to loading content via ajax), which means the width changes often!
So, I need to center the div after changing its width using jQuery.
I typically use this code for centering:
Unfortunately, when I change the div's width, it doesn't align to the center even after calling CenterItem function again!
In conclusion, I'm looking for something similar to what can be seen here: