[英]nextjs minimum image size?
Going through NextJS documentation and the built in optimization is impressive.浏览 NextJS 文档和内置优化令人印象深刻。 However, I can't seem to find any discussion on minimum width or height parameters.
但是,我似乎找不到任何关于最小宽度或高度参数的讨论。
NextJS - Image Docs NextJS - 图片文档
I could set both layout and objectfit to fill and have the parent div determine the height, but that's not as ideal as defining minimums for the image itself.我可以设置 layout 和 objectfit 来填充并让父 div 确定高度,但这不如为图像本身定义最小值那么理想。
How would I go about setting a minimum height or width for an image using the built-in component?我将如何使用内置组件设置图像的最小高度或宽度?
Hopefully I'm just blind.希望我只是个盲人。 Any thoughts would be appreciated.
任何想法将不胜感激。
I resolved the issue as follows - would be curious if there is a better solution so please comment if you disagree with the following:我按如下方式解决了这个问题 - 如果有更好的解决方案,我会很好奇,所以如果您不同意以下内容,请发表评论:
<div className={styles.imageDiv}>
<Image src={localImage}
height={50} // this doesn't set size, this is just for ratio
width={50}
layout='responsive'
alt='image description'
/>
</div>
The CSS: CSS:
.imageDiv {
display: block;
min-width: whatever you want;
// this is also how you would set max-width
// this method also allows height or width to be auto
}
Maybe a dumb issue to get caught on.也许是一个愚蠢的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.