【发布时间】:2021-05-16 09:04:53
【问题描述】:
我正在尝试将 Next.js 的 <Image> 组件与 layout=fill 选项一起使用。因此我创建了一个包含Image 标签的relative div。但我想通过图像高度来确定高度。
找到this example,但那里是静态给出的高度。所以我已经根据示例进行了尝试。
<div className="relative w-full h-full">
<Image
src={post.coverImage.url}
layout="fill"
alt={post.title}
/>
</div>
我也尝试过h-full 或max-h-full 类而不是h- 标签,但未能成功。
如何自动确定其高度?
【问题讨论】:
标签: css next.js tailwind-css nextjs-image