css - 如何在可滚动容器中拉伸 flex 子项
问题描述
我有一个固定宽度和overflow-x: auto
. 其中一个孩子也有固定宽度,大于容器的宽度,因此出现水平滚动条。如何拉伸容器中的另一个孩子以包括滚动区域宽度?
<div class="picture">
<img src="https://picsum.photos/id/715/800/200" width="800" height="200">
<div class="text">Lorem, ipsum dolor.</div>
</div>
.picture {
display: flex;
flex-direction: column;
align-items: stretch;
width: 600px;
overflow-x: auto;
border: 1px solid black;
}
.text {
display: flex;
align-items: center;
justify-content: center;
height: 100px;
color: white;
background-color: tomato;
}
解决方案
推荐阅读
- haskell - Xmonad,无法将类型“ModifiedLayout(Sublayout(ModifiedLayout SmartBorder Simplest))l0 a0”与“GHC.Word.Word64”匹配
- python - “无法加载插件:%s:%s”%(self.group,名称)sqlalchemy.exc.NoSuchModuleError:无法加载插件:sqlalchemy.dialects:postgres我该怎么做
- elixir - 什么是使用捕获语法传递的内核函数?
- bootstrap-4 - 带有 Bootstrap 的 Angular 编译器警告
- asp.net-core - Blazor 服务器端 => 没有身份脚手架的身份验证可能吗?
- typescript - 如何协调 monorepo 与多个 tsconfig.json,每个 tsconfig.json 都有自己的路径?
- java - 令人困惑的结果测试两个线程使用同步方法递增单个 int
- php - 请求过滤器时获取密钥
- spring-boot - 使用 Kotlin 和 Spring Boot 配置 DbSetup
- azure - 从 Azure ADDS 到 On Prem 的一种信任方式失败