css - 处理 div 的重叠
问题描述
我希望红色圆圈的内部为白色,同时与蓝色圆圈重叠,其余部分透明,以便您可以看到绿色。
如果有人知道如何处理这个问题,我会很高兴。
#bigCircle {
display: flex;
justify-content: center;
align-items: center;
width: 380px;
height: 380px;
border-radius: 50%;
background-color: rgba(11, 122, 30, 0.8);
}
#middleCircle {
display: flex;
justify-content: center;
align-items: center;
width: 240px;
height: 240px;
border-radius: 50%;
background-color: rgba(0,0,250,0.5);
}
.smallCircle {
margin-top: -244px;
margin-left: 1px;
border: solid rgb(226, 85, 20);
width: 13px;
height: 13px;
border-radius: 50%;
background-color:rgba(255,255,255,0);
}
<div id="bigCircle">
<div id="middleCircle">
<div class="smallCircle" />
</div>
</div >
解决方案
将 aradial-gradient
作为您固定的背景颜色并与蓝色圆圈具有相同的位置:
#bigCircle,
#middleCircle{
display: flex;
justify-content: center;
align-items: center;
width: 380px;
height: 380px;
border-radius: 50%;
background-color: rgba(11, 122, 30, 0.8);
}
#middleCircle {
width: 240px;
height: 240px;
background-color: rgba(0, 0, 250, 0.5);
}
.smallCircle {
margin-top: -244px;
margin-left: 1px;
border: solid rgb(226, 85, 20);
width: 50px;
height: 50px;
border-radius: 50%;
transition:1s all;
background:radial-gradient(circle 120px at 190px 190px,#fff 99%,transparent 100%) fixed;
}
#middleCircle:hover .smallCircle {
margin-top: -100px;
}
body {
margin:0;
}
<div id="bigCircle">
<div id="middleCircle">
<div class="smallCircle" ></div>
</div>
</div>
推荐阅读
- sql-server - 带有 CASE & NOT IN 条件的 SQL Where 子句
- django - Django 验证包含在基本模板中的(通讯)表单
- python - 生成给定点 10 公里内的纬度/经度列表
- javascript - 具有_任何可能的属性_的无限深度对象定义为既是又返回另一个无限深度对象的函数。JS
- javascript - 计算传感器未确定长度的运行平均值
- r - 使用 RAdwords 库连接并使用 doAuth 会出错
- opencv - 尝试使用 cmake-gui 构建“opencv_contrib”时出错
- selenium - 特定于在 TestNG 中测试的 SoftAssertion
- php - Woocommerce 中的自定义删除购物车项目功能
- fabricjs - 将对象剪辑到使用免费画笔绘制的路径