html - 使多个div在中心环绕一个圆圈并响应移动设备

标签 html css geometry

我希望 div 框内的 div 围绕圆形图像,并且我想让它响应移动显示。我的意思是我也想在移动设备中查看 div 周围的圆圈。这是我的代码-

<div class="circle">
  <img src="images/circle.jpg height="500px" width="500px" alt="circle">
  <div class="boxes">
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
    <div class="box4"></div>
  </div>
</div>

下面是我用的css-

<style>
  .circle{position:relative}
  .circle img{max-width:100%; height:auto}
  .boxes{position:absolute; top:0; left:0}
  .boxes div{height:50px; width:50px; display:inline-block}
</style>

最佳答案

试试这个会起作用

<html>
            <head>
                <title>TODO supply a title</title>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <style>
                    .divname{
                        height: 200px;
                        width: 32%;
                        border:1px solid red;
                        float: left;
                    }
                    .notadiv{
                        visibility: hidden;
                    }
                </style>
                <script>
                    function  setwidth() {
                        var part = (window.innerWidth / 3) - 30;
                        function  setwidth() {
                            var part = (window.innerWidth / 3) - 30;
                            alert(part.toString());
                            var x = document.getElementsByClassName("divname");
                            var i;
                            for (i = 0; i < x.length; i++) {
                                x[i].style.width = part.toString();
                            }
                        }
                    }
                </script>
            </head>
            <body onresize="setwidth();">
                <div style="text-align: center;">
                    <div  class='divname notadiv' ></div>
                    <div  class='divname' >1</div>
                    <div  class='divname notadiv' ></div>
                    <div  class='divname' >2</div>
                    <div class='divname' style="background-image: url('images/circle.jpg');border:0px solid transparent;background-size: contain;background-repeat: no-repeat;background-position: center;"></div>
                    <div  class='divname' >3</div>
                    <div  class='divname notadiv' ></div>
                    <div  class='divname' >4</div>
                    <div  class='divname notadiv' ></div>
                </div>
            </body>
        </html>

关于html - 使多个div在中心环绕一个圆圈并响应移动设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31165146/

相关文章:

javascript - 推特 Bootstrap : Uncaught TypeError: Object modal1 has no method 'toggle'

html - 调整伪元素图像的大小以匹配容器

html - 如果可以的话,我想让我的 flex box 进入 2 x 2 网格帮助

javascript - 将 Canvas 宽度和高度缩放到尽可能大但保持纵横比(JS)

jQuery - 快速点击后标签/输入中断的切换类

html - 自定义多边形形状

algorithm - 用较小的球体最佳地填充 3D 球体

c++ - 如何找到距离等于 X 的两个 vector 上的点

algorithm - 形成三角形

javascript - 提交前检查 JS 表单