How to perfectly align text vertically in tailwind css?

Member

by brandy , in category: HTML & CSS , 4 months ago

How to perfectly align text vertically in tailwind css?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by gilbert , 4 months ago

@brandy 

To align text vertically in Tailwind CSS, you can use utilities like align-middle, items-center, or flex. Here are a few ways to align text vertically:

  1. Using items-center utility class:
1
2
3
<div class="flex items-center justify-center h-16">
  <p class="text-center">Centered vertically</p>
</div>


  1. Using flex utility class:
1
2
3
<div class="flex items-center justify-center h-16">
  <p class="flex">Centered vertically</p>
</div>


  1. Using align-middle utility class:
1
2
3
<div class="h-16 flex justify-center align-middle">
  <p>Centered vertically</p>
</div>


You can adjust the height (h-16 in the examples above) and other properties in the utilities to align the text vertically according to your needs.