【发布时间】:2018-12-23 00:54:23
【问题描述】:
我有以下代码
.parent {
display: flex;
width: 100%;
flex-direction: column;
overflow-x: auto;
}
.child {
display: flex;
flex-flow: row nowrap;
background: red;
}
.grand-child {
flex-shrink: 0;
display: block;
align-items: center;
padding: .54rem 1.05rem;
width: 300px;
height: 100px;
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
<div class="parent">
<div class="child">
<div class="grand-child">a</div>
<div class="grand-child">b</div>
<div class="grand-child">c</div>
<div class="grand-child">d</div>
</div>
</div>
问题:
将背景应用于.children 类时,背景不会溢出内容(通过 x 轴滚动时)。我想保持可滚动性,同时仅将背景应用于.children 类。如果这不可能是什么原因?
我在回答 This 时遇到了这个问题。虽然我设法解决了这个问题,但这个特定问题仍然存在
【问题讨论】:
-
请好好解释一下这个问题...你想要的输出是什么?
-
嗨 @DreamHunter 请运行 sn-p 并滚动 x 轴,您会看到红色背景没有覆盖整个
.childrendiv。我想知道为什么