css - 图像按高度缩放
问题描述
我正在尝试将图像放入 div 中,并且 div 的高度是动态的,所以我遇到了图像溢出 div 的问题。
这是一个游乐场:https ://jsfiddle.net/fibin/yzox154p/2/
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
background: red;
height: 1000px;
max-height: calc(100vh - 100px);
padding: 50px;
}
img {
max-width: 100%;
}
<div class="wrapper">
<div>
some capture
</div>
<h2>
some header
</h2>
<p>
some description
</p>
<img src="https://filedn.com/ltOdFv1aqz1YIFhf4gTY8D7/ingus-info/BLOGS/Photography-stocks3/stock-photography-slider.jpg"/>
<span>1/3</span>
</div>
解决方案
推荐阅读
- visual-studio-code - 如何在 VSCode 工作区中创建指向文件的链接
- asp.net-core - 在 ASP.NET Core 的约束中覆盖 RouteValueDictionary
- android - 如何在 android 中实现这种海浪进度(查看此 gif 图像)?
- python - 有没有办法找到每个组合以从每个列表中选择一个元素(在列表中)?
- python - 如何解决'列标签'Avg_Threat_Score'不是唯一的。'?熊猫的问题
- azure-ad-b2c - B2C OpenID 与 Azure AD 连接
- java - 如何将我的业务与 whatsup 业务 api 集成?
- rust - 在 Rust 中重用变量
- java - 限制聚合返回的存储桶大小
- node.js - 无法连接/调用其他节点的服务 Moleculer NodeJs