开发者

How to find offsetWidth with a multiline element?

I've built a tooltip where I calculate the position for the tooltip from the hovered element's offsetWidth and offsetHeight, that works great with one exception: When the element which is to be hovered over runs down onto the next line the elements offsetWidth becomes much larger and therefore sends the tooltip the开发者_如何学Python width length away from the element.

Whats the best way to handle that? I'd like to avoid repositioning the tooltip to where the mouse is as that wouldn't be as aesthetically appealing and would be a larger re-factor.

Note: Javascript only, no jQuery please.


The solution from my comment above resolved it for me. Thank you for the suggestions.

I basically added the css element "display: inline-block" to the multi-line element and it worked IE6-9 FF & WEbkit.

Note that IE 5.5-7 may have issues with display: inline-block.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜