I won't explain the problems related to this stuff again because they are well explained in other posts. Just will point a possible solution, it has some bug but it's a starting point.
Fortunately there is a scrip on Github to calculate the caret position relative to it's container, but it requires jQuery. GitHub page here: jquery-caret-position-getter, Thanxs to Bevis.Zhao.
Based on it I have implemented the next code: check it in action here in jsFiddle.net
- jsFiddle demo by mjerez
Click ctrl+space to while you write to diplay the autocmplete pannel.
- Option a
- Option b
- Option c
- Option d