html - 如何在 CSS 中的 div 中居中两个重叠的圆圈?
问题描述
我试图在一个 div 中居中两个重叠的圆圈,但由于 margin-right -100 的样式,它不起作用。这就是导致它们重叠的样式。我试图在它周围的 div 上设置 margin: 0 auto 的样式,但它不起作用。我还尝试使用一些引导程序并制作列来帮助它们居中,但到目前为止没有任何效果。我在下面添加了一个 codepen 以进行适当的演示。
#projects {
background-color: #3f4756;
width: 100%;
height: auto;
text-align: center;
padding-top: 15em;
padding-bottom: 10em;
margin: 0 auto;
}
#projects h2{
color: white;
font-family: BrandonGrotesque, Brandon Grotesque;
font-size: 3.75em;
margin-bottom: 1.5em;
font-style: normal;
font-weight: 500;
letter-spacing: 2px;
}
.circle {
display: inline-block;
height: 30em;
width: 30em;
line-height: 18px;
border-radius: 50%;
color: white;
margin: 0 0 0 -100px;
}
#projects > a:nth-child(3){
position: relative;
z-index: 1;
background-color:#a3abbd;
text-decoration: underline;
}
#projects > a:nth-child(2){
position: relative;
z-index: 2;
background-color: #a4844e;
text-decoration: underline;
}
#projects > a:nth-child(2) > p, #projects > a:nth-child(3) > p {
margin-top: 4em;
font-size: 3em;
font-family: BrandonGrotesque, Brandon Grotesque;
font-weight: 350;
}
<div id="projects" class="skew">
<h2>My Projects</h2>
<a href="#" class="circle">
<p>web</p>
</a>
<a href="#" class="circle">
<p>graphics</p>
</a>
</div>
解决方案
推荐阅读
- javascript - 玩笑测试 onClick 的 util 功能
- azure - Cosmos 查询以获取列表中的项目
- python - 当我没有“y”输出时,如何向我的 Keras 生成器添加样本权重?
- html - 负边距如何在引导轮播中起作用?
- excel - 如何将带有 INDEX 函数的列“绑定”到 Excel 中的公式中?
- datomic - 存储故障下的原子持久性保证
- ruby-on-rails - Parse a call transcript into array of hash - Ruby
- r - 使用 cat 函数写入 csv 文件
- java - Maven 不包括 sqlite-jdbc
- php - 如何修复在 leven 主题中拒绝导入的演示内容?