以下CSS网格代码在Chrome和IE中的行为与在FF中的行为不同。
https://codepen.io/inkOrange/pen/XGzeMo布局设计为当溢出的内容不适合时水平滚动,正如我在此演示中所强制的那样。
外部容器固定在900px。在Chrome(72.0)中检查.TableRow网格容器时,宽度为:1010px,强制水平滚动条。
但在FF(65.0)中,它读取的边界宽度小于885px,没有溢出/滚动条。
.TableRow的内容扩展到两个浏览器中的边界容器之外,但FF似乎无法解析基于css-grid的元素的真实宽度。
我怎样才能为FF解决这个问题?我希望.TableWrapper上有一个滚动条
HTML:
<div style="width: 900px; overflow: auto;">
<section class="TabularListing">
<section class="TableWrapper">
<div class="TableHeaderContainer">
<div></div>
<div><label style="cursor: pointer;">Dest</label></div>
<div><label style="cursor: pointer;">Opened</label></div>
<div><label style="cursor: pointer;">Cube</label></div>
<div><label style="cursor: pointer;">Y<em>(ft)</em></label></div>
<div><label style="cursor: pointer;">Z<em>(ft)</em></label></div>
<div><label style="cursor: pointer;">Z<em>(ft)</em></label></div>
<div><label style="cursor: pointer;">Weight</label></div>
</div>
<div class="TableBodyContainer">
<div class="TableRow">
<div></div>
<div><span data-filterable="true" data-value="BILL">BILL</span></div>
<div><span>1380233679000</span></div>
<div><span>72</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
</div>
<div class="TableRow">
<div></div>
<div><span data-filterable="true" data-value="BILL">BILL</span></div>
<div><span>1380233679000</span></div>
<div><span>72</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
</div>
<div class="TableRow">
<div></div>
<div><span data-filterable="true" data-value="BILL">BILL</span></div>
<div><span>1380233679000</span></div>
<div><span>72</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
</div>
<div class="TableRow">
<div></div>
<div><span data-filterable="true" data-value="BILL">BILL</span></div>
<div><span>1380233679000</span></div>
<div><span>72</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
</div>
<div class="TableRow">
<div></div>
<div><span data-filterable="true" data-value="BILL">BILL</span></div>
<div><span>1380233679000</span></div>
<div><span>72</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
<div><span>94</span></div>
</div>
</div>
</section>
</section>
</div>
CSS:
.TabularListing {
position: relative;
.TableWrapper {
display: grid;
grid-template-rows: 64px calc(136px);
overflow: auto hidden;
.TableHeaderContainer {
background-color: white;
min-height: 24px;
max-height: 64px;
overflow: hidden;
display: grid;
width: 100%;
grid-template-columns: 50px 250px 180px 130px minmax(100px, 12.5%) minmax(100px, 12.5%) minmax(100px, 12.5%) minmax(100px, 15%);
border-bottom: 1px solid rgb(224, 224, 224);
> div {
box-shadow: rgba(0, 0, 0, 0) 0px -1px 0px 0px inset, rgb(224, 224, 224) 0px -1px 0px inset; transition: all 0.5s ease 0s;
opacity: 0.75;
padding: 20px 38px 20px 60px;
cursor: default;
overflow: hidden;
text-overflow: ellipsis;
font-size: 1.3rem;
font-weight: 400;
text-align: left;
line-height: 1.5rem;
color: rgb(33, 33, 33);
vertical-align: top;
background-color: white; position: relative;
}
}
.TableBodyContainer {
overflow: hidden auto; width: 100%;
.TableRow {
display: grid;
grid-template-columns: 50px 250px 180px 130px minmax(100px, 12.5%) minmax(100px, 12.5%) minmax(100px, 12.5%) minmax(100px, 15%); transition: box-shadow 0.25s ease 0s;
background-color: white;
border-bottom: 1px solid rgb(224, 224, 224);
cursor: pointer;
min-height: auto;
> div {
padding: 20px 40px 20px 60px;
cursor: default;
overflow: hidden;
text-overflow: ellipsis;
font-size: 1.3rem;
text-align: right;
position: relative;
}
}
}
}
}
当您从overflow: hidden
中删除.TableHeaderContainer
时,它似乎适用于各种浏览器。