I have a bootstrap icon on the top right of a div that I'd like to be inline with a horizontally centered <p>
. However, if I use float:right
, the text shifts ever so slightly.
Is it possible to accurately center the text while the icon stays on the right?
Sample code here: https://jsfiddle.net/x1Lvyu6t/3/
.box {
border: 1px black solid;
width: 50%;
}
.subbox {
margin-left: auto;
margin-right: auto;
border: 1px black solid;
text-align: center;
}
p {
text-align: center;
margin: 0;
}
i {
float: right;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
<div class=box>
<i class="bi bi-question-circle"></i>
<p>
hello
</p>
<div class=subbox>
Content
<br> Content
<br> Content
</div>
</div>