我正在尝试使某个图标出现在某些文本的后面,但是它不起作用。我用于图标的CSS链接如下:
.fa:not(.form-control-feedback) {
font-size: $h1-size;
color: lighten($brand-color-light, 10%);
z-index: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: -webkit-box; /* Safari */
display: flex;
align-items: center;
justify-content: center;
}
和HTML是这样的:
<a ui-sref="account({ accountNumber: controller.account.accountNumber })" animated-tile>
<i class="fa fa-user"></i>
<div style="z-index: 2;">
<h3>{{ controller.account.accountNumber }}</h3>
<h5>{{ controller.account.name }}</h5>
<p>
{{ controller.account.address.houseName }}<br ng-if="controller.account.address.houseName.replace(' ', '')" />
{{ controller.account.address.street }}<br ng-if="controller.account.address.street.replace(' ', '')" />
{{ controller.account.address.town }}<br ng-if="controller.account.address.town.replace(' ', '')" />
{{ controller.account.address.county }}<br ng-if="controller.account.address.county.replace(' ', '')" />
{{ controller.account.address.postCode }}
</p>
</div>
</a>
但文字仅显示在图标后面。我已经尝试使用:before,但仍然无法正常工作。
这是我的问题的代码笔:
http://codepen.io/r3plica/pen/GZeLQM
这是我设置的位置:之前
http://codepen.io/r3plica/pen/EKMJLj
有人知道如何解决这个问题吗?
相对于h3和p添加位置,或将它们放在div中并相对于div添加位置。
.tile {
max-width: 200px;
height: 200px;
color: white;
background-color: blue;
position: relative;
}
.tile h3,
.tile p {
position: relative;
}
.tile .fa {
font-size: 50px;
color: red;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 0;
display: -webkit-box;
/* Safari */
display: flex;
align-items: center;
justify-content: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-3 tile">
<i class="fa fa-user"></i>
<h3>This is a test</h3>
<p>This is an issue when the text is behind the actual font-awesome icon. Does anyone know how to solve it?</p>
</div>
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句