【发布时间】:2021-10-29 15:01:36
【问题描述】:
const Product = ({product}) => {
return (
<div className="rounded shadow flex-col justify-center overflow-hidden">
<img className="" src={product.image} />
<span className="block h-16">{product.name}</span>
<span className="block">{product.price}</span>
<button className="px-4 py-2 my-2 bg-green-200 rounded block">Add to Cart</button>
</div>
)
}
这是 React 中使用 Tailwind CSS 的卡片组件。 我无法让项目在卡片中居中。
我使用了 flex-col,所以现在方向是垂直的,并尝试了 justify-center 和 items-center with tailwind,但它似乎没有移动任何东西。
如果您使用 flex-col,轴不会被交换,因此您需要使用 align-items: center 使其垂直居中?
【问题讨论】:
标签: reactjs flexbox tailwind-css