简体   繁体   English

对图像的响应点

[英]Responsive points over image

I have to build a map of a shopping maal, which will be responsive. 我必须建立一个购物邮箱的地图,这将是响应。

This looks like this on big screen : 这在大屏幕上看起来像这样:

在此输入图像描述

And it looks like this when I reduce the size of my window : 当我缩小窗口大小时它看起来像这样: 小决议

So as you can see the points moves .. Which is not good. 所以你可以看到点移动..哪个不好。

Here is my html : 这是我的HTML:

<div class="container">
  <div id="plan-boutiques"><img src=IMG></img>
    <a href="" id="first_element"><p></p></a>
    <a href="" id="second_element"><p></p></a>
    <a href="" id="third_element"><p></p></a> <!-- There will be 30 elements at the end -->
  </div>
</div>

And here is the css I'm using : 这是我正在使用的CSS:

#plan-boutiques > img {
  width: 100%;
  height: auto;
  max-width: 685px;
  max-height: 374px;
 }
.container {
  width:100%; 
  margin:0 auto;
}

 #plan-boutiques a {
  background-color: red;
  border-radius: 100px;
  background-repeat: no-repeat;
  display:block;
  height:10px;
  width:10px;
  position:absolute;
  line-height: 25px;
  color:#fff;
  text-align:center;
  font-size:1px;
  background-position: 0 -27px;
 }

#plan-boutiques a:hover {
  background-position: 0 0;
}  
a#first_element {
  margin-left: 20px;
  margin-top: -30px;
}
<!-- other element have differents margin -->

I tried to use % but it's worse it moves a every pixel the window is reduced. 我尝试使用%,但更糟糕的是它移动窗口减少的每个像素。 Here it only moves when the window is reduced at the max. 这里只有当窗口减少到最大值时才会移动。

The fiddle : http://jsfiddle.net/vqy8kq2f/ 小提琴: http//jsfiddle.net/vqy8kq2f/

You can use percentages if you add to your CSS #plan-boutiques { display: inline-block; position: relative; } 如果你添加到CSS #plan-boutiques { display: inline-block; position: relative; }你可以使用百分比#plan-boutiques { display: inline-block; position: relative; } #plan-boutiques { display: inline-block; position: relative; } #plan-boutiques { display: inline-block; position: relative; } . #plan-boutiques { display: inline-block; position: relative; }

Here is your fiddle with my modifications. 这是我修改的小提琴

Just remove width: 100% from #plan-boutiques > img 只需从#plan-boutiques > img删除width: 100%

FIDDLE 小提琴

EDIT 编辑

So i added some jQuery to calculate exact location of the dots and recalculate it if the image gets smaller than the mentioned size 所以我添加了一些jQuery来计算点的确切位置,如果图像小于上述大小,则重新计算它

FIDDLE 小提琴

ps: you will have to click run every time you resize the box. ps:每次调整框大小时都必须单击运行。 Also you can add $(window).resize() function if you want a real time response. 如果您想要实时响应,还可以添加$(window).resize()函数。

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

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