Tailwind-CSS-Centering-Issue-with-Padding-and-Rounded-Corners-v4ykf Tailwind Templates

Tailwind Css Centering Issue With Padding And Rounded Corners V4ykf

Tailwind CSS centering issue: Text within a div with padding and rounded corners is not vertically centered despite using standard Tailwind classes.

Tailwind CSS Centering Issue

This repository demonstrates a common issue encountered when using Tailwind CSS to center text within a div that has padding and rounded corners. The text fails to align vertically as expected. The solution is shown in bugSolution.js

Problem

The issue stems from the interaction of padding and the text-center class. The padding around the text element prevents accurate vertical centering. The solution below addresses this.

Solution

The provided solution uses flexbox to easily achieve the vertical and horizontal centering.

Top categories

Loading Svelte Themes