简体   繁体   English

jQuery:计算图像映射区域的大小并在中间显示div

[英]jQuery: Calculate Image Map area size and show div in the middle

I need to show div while Image Map area hover (something like tooltip ). 我需要在Image Map区域悬停时显示div(类似于tooltip)。

That's ok, but the problem is that I need to show div on the middle of each area, which are in different shapes and sizes. 可以,但是问题是我需要在每个区域的中间显示div,它们的形状和大小不同。 I don't want to use any tooltip plugin, as the content of it should be easy to change. 我不想使用任何工具提示插件,因为它的内容应该易于更改。

The jsfiddle is in comment. jsfiddle正在评论中。

I don't have deep knowledges of jQuery, that's why I need you help for that)) Thanks! 我对jQuery不了解,所以我需要您的帮助))谢谢!

If I understand correctly , you have an image map where you want to put a pointer to the center . 如果我的理解正确的话,您会有一个图片映射,您想要在上面放一个指向中心的指针。

Try this 尝试这个

var width = jQuery("#imageMaps").attr("width");
var height = jQuery("#imageMaps").attr("height");

var width = width / 2;
var height = height / 2;

var Point =  jQuery("#div to position").style("margin-top",height);
var Point =  jQuery("#div to position").style("margin-left",width);

I assume you have the same div is the pointer to the image maps. 我假设您具有相同的div是指向图像映射的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM