We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在做一个页面的时候,对一批图片(缩略图)有如下要求:
.img-container>img { width: 160px; height: 160px; object-fit: contain; }
object-fit 属性可以让图片在父容器中保持原始比例显示。
object-fit
contain
none
scale-down
The text was updated successfully, but these errors were encountered:
No branches or pull requests
需求描述
在做一个页面的时候,对一批图片(缩略图)有如下要求:
解决方案
属性值分析
object-fit
属性可以让图片在父容器中保持原始比例显示。contain
时,图片会保持原始比例显示,同时长边与父元素尺寸相同。none
时,图片会保持原始比例和原始尺寸显示。scale-down
时,图片会保持原始比例显示,同时在属性值contain
和none
之间选择最终尺寸更小的那个。参考资料
The text was updated successfully, but these errors were encountered: