html - 响应式布局:Safari 上的拉伸图像
问题描述
这是我的布局。
期望的行为是,当我垂直调整窗口大小时,图像缩放保持原始纵横比。
我的代码在除 Safari 之外的所有浏览器中都运行良好(您可以通过在不同浏览器中尝试该代码段来查看它)。
你有解决方案吗?谢谢 ;)
.wrap-container{
width: 100%;
display: flex;
justify-content: center;
background-color: yellow;
height: 55vh;
}
.wrap{
width: 700px;
background-color: aqua;
display: flex;
justify-content: flex-start;
align-items: flex-end;
padding-top: 64px;
}
.wrap img{
height: 100%;
width: auto;
max-width: 300px;
max-height: 300px;
}
<div class="wrap-container">
<div class="wrap">
<img src="https://via.placeholder.com/300"/>
</div>
</div>
解决方案
flex: 0;
在图像上添加
.wrap-container{
width: 100%;
display: flex;
justify-content: center;
background-color: yellow;
height: 55vh;
}
.wrap{
width: 700px;
background-color: aqua;
display: flex;
justify-content: flex-start;
align-items: flex-end;
padding-top: 64px;
}
.wrap img{
height: 100%;
width: auto;
flex: 0;
max-width: 300px;
max-height: 300px;
}
<div class="wrap-container">
<div class="wrap">
<img src="https://via.placeholder.com/300"/>
</div>
</div>
推荐阅读
- python - 如何将列添加到 numpy 数组
- flutter - 此函数的返回类型为“Row”,但不以 return 语句结尾
- javascript - select2 我不想从 json 中获取数据
- mysql - 如何在 Node/Express 中为数组的每次迭代发送 Post 请求?
- c# - 如何将 HTML 文本添加到工具提示 WPF
- javascript - childComponent中嵌套对象数组formik和handleChange的问题
- node.js - Nextjs如何在转到下一页时不卸载上一页(保持状态)
- asp.net - 如何使用asp.net 4.0在代码后面获取html chekbox
- python - 如何使用python循环在现有的csv文件中编写完整的字典
- c# - 'await _context.SaveChangesAsync ();'线上出现错误 在 C# 中的 POST api 中