html - 绝对定位到 img 的 Div 不应移动

标签 html css

我遇到了以下问题:父亲内部有两个 sibling div,一个有一个图像(位置相对和类 home-image),另一个(位置绝对和 box-circle)有一个 child (一个名为 div白色圆圈,图像后面有一个圆圈,绝对位置)。 我的问题是:当我改变分辨率时,圆圈应该留在图像后面并移开。

enter image description here

enter image description here

这是相对的CSS:

.box-circle{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}
.home-image{
  z-index: 10;
}
.relative{
  position: relative;
}
.white-circle{
      position: absolute;
    width: 25rem;
    height: 25rem;
    background-color: #FFFFFF;
    border-radius: 50%;
  top: 12rem;
    right: 8rem;
}

最佳答案

z-index CSS 属性指定了 positioned 元素的 z-order,因此将 position 属性插入到 .home-image 中,例如这个:

.home-image{
  z-index: 10;
  position:relative;
}

关于html - 绝对定位到 img 的 Div 不应移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50504658/

相关文章:

html - 如何使元素水平居中?

javascript - 输入字段上的 Angular 条件只读/禁用

asp.net - 使用适合 Ipad 的新 css 将网站定向到 Ipad

css - 如何隐藏在我的 WebM 视频的循环之间弹出的 MediaElement.js 视频播放器加载图标?

jquery - 滚动后更改 css 标题

Python Django 电子邮件表单示例

javascript - 如何在清除本地存储的同时清除缓存

CSS 对齐单选/复选按钮

html - li/navigation 元素下的小边框

css - 顺时针旋转 180 度再旋转 360 度