#top {
height: .5rem;
padding-left: 2.7rem;
line-height: .5rem;
color: #666;
font-size: .12rem;
position: relative;
background-color: rgb(241, 241, 241);
}
#top div {
position: absolute;
right: .18rem;
top: 50%;
transform: translateY(-50%);
font-size: .14rem;
line-height: .20rem;
}
#top .icon {
font-size: .28rem;
}
<section id="top">
<div>
allMessages
<svg class="icon record-info" aria-hidden="true">
<use xlink:href="#icon-wenjuan"></use>
</svg>
</div>
</section>
https://i.sstatic.net/6EjdD.png
I aim to place the "allMessages" text in the center of the div.
However, when I adjust the line-height
for the #top div
, the "allMessages" text always ends up aligned with the bottom of the svg
.
What is the best method to ensure that the 'allMessages' text is positioned at the same level as the middle of the svg
.