简体   繁体   English

使用引导框架在图像上覆盖CSS点

[英]CSS Dot overlay on image with bootstrap framework

I have a "map" that's basically just a line in .png format (attached an example image). 我有一个“地图”,基本上只是.png格式的一行(附带示例图像)。 I am using a red dot in css that I want to overlay on the map. 我在要在地图上覆盖的CSS中使用了一个红点。 I use javascript to change the positioning of the dot based on a function. 我使用javascript基于函数更改点的位置。

My problem is that I can't figure out how to make the dot compatible with bootstrap. 我的问题是我不知道如何使点与引导程序兼容。 Such as when the browser size is changed, the map and dot move together. 例如,当浏览器大小更改时,地图和点将一起移动。

The dot will be moving along the line based on a percentage that is calculated using a JS function so if the function outputs 10%, the red dot will be placed at 10% of the blue line. 点将根据使用JS函数计算的百分比沿线移动,因此,如果该函数输出10%,则红点将放置在蓝线的10%处。

在此处输入图片说明

.reddot {
    height: 25px;
    width: 25px;
    background-color: #D03C3C;
    border-radius: 50%;
    display: inline-block;
    position: absolute;
    top: 300px;
    left: 300px;
}

<div style="position: relative; left: 0; top: 0;">
      <img src="/imgs/map.png" alt="Map" style="width:100%;">
      <div class="reddot">
      </div>
</div>

use vw instead of px when sizing and positioning 调整大小和位置时使用vw而不是px

 .reddot { height: 4vw; width: 4vw; background-color: #D03C3C; border-radius: 50%; display: inline-block; position: absolute; top: 20vw; left: 20vw; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div style="position: relative; left: 0; top: 0;"> <img src="https://i.stack.imgur.com/VjwsQ.png" alt="Map" class="img-fluid" style="width:100%;"> <div class="reddot"> </div> </div> 

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

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