I need to wrap the border around the text so it fits and center the text at the same time. I found a temporary solution in using display: inline;
makes the border fit the text but when I try to use text-align: center;
it does not align it. So I found using display: block;
fixed it but I can’t use display block and inline at the same time so I am stuck.
<p1 class="frequently">Frequently Ask Question</p1>
.frequently{
color: rgb(232 87 61);
border: solid rgb(251 244 239);
border-radius: 2rem;
display: block;
text-align: center;
}
2
Answers
Just add
width: fit-content
to your css, it works.Replace
display: block
withtext-align: center
. Or you can usedisplay: flex; justify-content: center