The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › [Solved] center align icon fonts horizontally
I can’t figure out how to txt-center icon fonts. They just don’t center no matter what you do.
example of css and html below
content: "\e610";color:#f16822;text-align: center;
Any ideas what’s going on?
From the example you give the before element doesn’t have a width, so the element is only as wide as the content. There’s no space for it to “center”.
Now, if you add width like this.
that will let it be centered. Also you need the display: block for it to work. If you have other content in the div and you want the before element to be to the left of it. You’ll need to use display: inline-block;
You can check out this pen for an example.
Thank you, that saved the day