.x {
text-align: center;
}
.y {
display: inline-block;
}
.x img, .y {
vertical-align: middle;
}
<div class="clearfix x">
<img src="http://placehold.it/80x60/0fa" alt="Icon" class="pull-left">
<h4 class="y">Refinancing</h4>
</div>
.wrapper {
text-align: center;
}
.heading, img {
display: inline-block;
}
.heading {
vertical-align: top;
}
<div class="clearfix wrapper">
<img src="http://placehold.it/80x60/0fa" alt="Icon" class="pull-left">
<h4 class="heading">Refinancing</h4>
</div>
试试这个
<div class="clearfix text-center">
<img src="https://unsplash.it/400/180" alt="Icon" class="pull-left">
<h4>Refinancing</h4>
</div>
这个工作很好:
<div class="clearfix">
<div class="block">
<img src="your_icon.png" class="pull-left">
<h4>Refinancing</h4>
</div>
</div>
.clearfix{
/*your code ...*/
position:relative;
}
.block{
display:inline-block;
position:absolute;
left:50%;
transform:TranslateX(-50%);
}
pull-left
类,并添加了所需的 CSS 行。 .x {
text-align: center;
}
.y, img {
display: inline-block;
}
<div class="clearfix x">
<img src="http://localhost/chifley-acf/wp-content/uploads/2017/03/icon-01.png" alt="Icon" class="">
<h4 class="y">Refinancing</h4>
</div>