我正在尝试使用 Tailwind CSS 将红色圆形按钮中的“x”居中。我尝试了很多 css 但没有任何效果。什么可以解决它?
https://play.tailwindcss.com/Wz54NCHCI8
<button type="button" class="flex justify-center select-none bg-red-500 border-2 text-white
text-xl font-bold p-2 m-2 rounded-full shadow h-20 w-20 focus:outline-none
focus:shadow-outline"><img src="/icons/x.svg" alt="" width="40" h="40" class="icon svelte-1iu276v"></button>
Run Code Online (Sandbox Code Playgroud)
Kev*_*our 14
添加items-center将使您的图标垂直居中,并使justify-center您的图标水平居中。
代码:
<button type="button" class="flex justify-center items-center select-none bg-red-500 border-2 text-white text-xl font-bold p-2 m-2 rounded-full shadow h-20 w-20 focus:outline-none focus:shadow-outline">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
Run Code Online (Sandbox Code Playgroud)
结果:

| 归档时间: |
|
| 查看次数: |
15520 次 |
| 最近记录: |