Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在图片上添加圆形div_Html_Css - Fatal编程技术网

Html 在图片上添加圆形div

Html 在图片上添加圆形div,html,css,Html,Css,我试图在图片上添加一些带有文字的圆圈 在全屏模式下没有问题,但是当我调整窗口大小时,圆圈会移动而不是停留在它们的位置上 代码: 假设您的浏览器是最新的,我建议您使用容器 <!DOCTYPE HTML> <html> <head> <style> body { margin: 0px; padding: 0px; } </style> </head&g

我试图在图片上添加一些带有文字的圆圈

在全屏模式下没有问题,但是当我调整窗口大小时,圆圈会移动而不是停留在它们的位置上

代码:


假设您的浏览器是最新的,我建议您使用
容器

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="400"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      var imageObj = new Image();

      imageObj.onload = function() {
        context.drawImage(imageObj, 69, 50);
      };
      imageObj.src = 'http://linktoyourimage.jpg';
    </script>
  </body>
</html>
这将在画布中添加一个圆,基于给定半径的中心X,Y位置。您需要创建这些变量


作为补充说明,如果您开始使用html5特定的标记,那么它有一些很好的参考信息。

假设您的浏览器是最新的,我建议使用
容器

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="400"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      var imageObj = new Image();

      imageObj.onload = function() {
        context.drawImage(imageObj, 69, 50);
      };
      imageObj.src = 'http://linktoyourimage.jpg';
    </script>
  </body>
</html>
这将在画布中添加一个圆,基于给定半径的中心X,Y位置。您需要创建这些变量


作为旁注,如果你是从html5特定的标签开始,它有一些很好的参考信息。

只需设置正确的位置。主div可以是相对的,也可以是绝对的,因此圆是绝对的

看这把小提琴: 圆圈在原地不动。您可以调整窗口大小或调整JSFIDLE输出面板的大小

HTML:


只需设置正确的位置。主div可以是相对的,也可以是绝对的,因此圆是绝对的

看这把小提琴: 圆圈在原地不动。您可以调整窗口大小或调整JSFIDLE输出面板的大小

HTML:


您使用的是哪种浏览器?我问的原因是,听起来您的问题最好通过使用SVG或画布容器来解决。您使用的浏览器是什么?我问的原因是,听起来您的问题最好通过使用SVG或Canvas容器来解决。我不能尝试使用atm,但谢谢您的回答。当我不能尝试时,我会尝试实现它,但是谢谢你的回答。我会尽可能地实施它
   <div class=container>
      <img src=http://www.gimpfr.org/document/document_10/images/straight_line_example.png>
      <div class=circle1></div>
       <div class=circle2></div>

    </div>
.container{
  position:relative; margin: auto; width:478px; height:308px;
  }
  .circle1, .circle2 {background:red; width:20px; height:20px; border-radius:10px;}
  .circle1{position:absolute; top:10px; left:300px;}
  .circle2{position:absolute; top:50px; left:200px;}