我想创建一个圆角的div,有一个字体很棒的i箭头标签在它的like this:居中
我试图将i标记包装在一个div中,并自动将其居中,但它不能很好地居中,我该怎么做呢?
下面是我的html:
<div class="parent">
<div class="child">
<i class="fas fa-arrow-up"></i>
</div>
</div>和我的css:
.parent {
width: 300px;
background: #f00;
height: 300px;
margin: 0 auto;
border-radius: 50%;
}
.child {
width: 150px;
margin: auto;
height: 100px;
}发布于 2018-10-10 01:14:37
您可以使用stack fontawesome icons,所以只需使用圆圈和箭头:
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet"/>
<span class="fa-stack fa-2x">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-arrow-up fa-stack-1x"></i>
</span>
发布于 2018-10-10 01:14:16
您可以像这样将其居中:
.parent {
width: 300px;
background: #f00;
height: 300px;
margin: 0 auto;
border-radius: 50%;
}
.child {
width: 150px;
margin: auto;
height: 100px;
position: relative;
}
.child i {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}发布于 2018-10-10 03:36:08
.parent {
width: 300px;
background: #f00;
height: 300px;
margin: 0 auto;
border-radius: 50%;
}
.child {
font-size: 100px;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 25%;
left: 50%;
transform: translate(-50%, -50%);
}https://stackoverflow.com/questions/52726094
复制相似问题