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
Release: 2024-12-09 03:13:13
Original
300 people have browsed it

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">
Copy after login

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>
Copy after login
.my-icon {
    vertical-align: middle;
    font-size: 40px;
}
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template