vertical-align.mdx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---
  2. title: Vertical align
  3. description: Quickly and easily align elements vertically with utility classes.
  4. summary: Easily modify the vertical alignment of elements such as inline, inline-block, inline-table, and table-cell to ensure proper positioning and alignment within their parent containers, allowing for more precise control over your layout and design.
  5. ---
  6. Choose from `.align-baseline`, `.align-top`, `.align-middle`, `.align-bottom`, `.align-text-bottom`, and `.align-text-top` as needed.
  7. ## Inline elements
  8. Use vertical alignment utilities to align inline-level elements relative to their surrounding text or baseline. These classes are particularly useful for aligning small inline elements like icons or badges alongside text.
  9. ```html
  10. <span class="align-baseline">baseline</span>
  11. <span class="align-top">top</span>
  12. <span class="align-middle">middle</span>
  13. <span class="align-bottom">bottom</span>
  14. <span class="align-text-top">text-top</span>
  15. <span class="align-text-bottom">text-bottom</span>
  16. ```
  17. ```html example centered
  18. <div>
  19. <span class="align-baseline">baseline</span>
  20. <span class="align-top">top</span>
  21. <span class="align-middle">middle</span>
  22. <span class="align-bottom">bottom</span>
  23. <span class="align-text-top">text-top</span>
  24. <span class="align-text-bottom">text-bottom</span>
  25. </div>
  26. ```
  27. ## Table cells
  28. Vertical alignment utilities are also applicable to table cells, allowing you to control the alignment of content within a cell. This is especially useful for creating well-structured and visually appealing tables where the content aligns consistently across rows and columns.
  29. ```html
  30. <table>
  31. <tbody>
  32. <tr>
  33. <td class="align-baseline">baseline</td>
  34. <td class="align-top">top</td>
  35. <td class="align-middle">middle</td>
  36. <td class="align-bottom">bottom</td>
  37. <td class="align-text-top">text-top</td>
  38. <td class="align-text-bottom">text-bottom</td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. ```
  43. ```html example
  44. <table style="height: 100px;">
  45. <tbody>
  46. <tr>
  47. <td class="align-baseline">baseline</td>
  48. <td class="align-top">top</td>
  49. <td class="align-middle">middle</td>
  50. <td class="align-bottom">bottom</td>
  51. <td class="align-text-top">text-top</td>
  52. <td class="align-text-bottom">text-bottom</td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. ```