Home >Web Front-end >CSS Tutorial >How to Vertically Align Text with Font Awesome Icons in Bootstrap Buttons?

How to Vertically Align Text with Font Awesome Icons in Bootstrap Buttons?

Barbara Streisand
Barbara StreisandOriginal
2024-12-09 03:13:13291browse

How to Vertically Align Text with Font Awesome Icons in Bootstrap Buttons?

Vertical Alignment of Text with Font Awesome Icons

When combining Font Awesome icons and text in Bootstrap buttons, aligning the text vertically can be challenging. Typically, the text aligns with the bottom edge of the icon.

To achieve vertical text alignment, modify the vertical alignment of the Font Awesome icon instead of the text.

<div>
  <span class="icon icon-2x icon-camera">

Alternatively, you can separate the icon and text into individual spans and target them with CSS:

<div class='my-fancy-container'>
    <span class='my-icon icon-file-text'></span>
    <span class='my-text'>Hello World</span>
</div>
.my-icon {
    vertical-align: middle;
    font-size: 40px;
}

The above is the detailed content of How to Vertically Align Text with Font Awesome Icons in Bootstrap Buttons?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn