Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html flexbox表中的粘性标题不粘性_Html_Css_Flexbox - Fatal编程技术网

Html flexbox表中的粘性标题不粘性

Html flexbox表中的粘性标题不粘性,html,css,flexbox,Html,Css,Flexbox,我已经创建了一个基于flexbox的表,下面的示例将其剥离到基本内容 <!-- display: flex;flex-flow: column nowrap; flex:1 1 auto; --> <div class="ovdTable"> <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; --> <div class="ovdTable__t

我已经创建了一个基于flexbox的表,下面的示例将其剥离到基本内容

<!-- display: flex;flex-flow: column nowrap; flex:1 1 auto; --> 
<div class="ovdTable"> 
  <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
  <div class="ovdTable__table">  
    <!-- flex:1 1 auto; -->
    <div class="ovdTable__column">   
      <!-- display:flex; flex:none; -->                    
      <div class="ovdTable__cell ovdTable__cell--header"> 
      <!-- 1-n -->
      <div class="ovdTable__cell">                 
    </div>
  </div>
</div>
正如所料,我已经搜索了类似的stackoverflow文章,并尝试了在那里找到的解决方案

    • 检查父元素是否有
      溢出-x:隐藏
    • 在粘滞元素中添加了
      align self:flex start
    • 在这里找不到任何有用的信息
我有一个代码笔的例子


也许我完全错了,但是我可能在溢出设置中出错了吗?

我可以通过在div中添加一个额外的div来解决这个问题,该div的类“ovdTable”包含标题单元格,并使该div具有更高的z索引“粘性”

<!-- display: flex;flex-flow: column nowrap; flex:1 1 auto; --> 
<div class="ovdTable"> 
    <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
    <!-- position: sticky; top:0px; z-index:2; --> 
    <div class="ovdTable__tableHeader"> 
      <!-- 1-n -->
      <div class="ovdTable__tableHeader--column">Column 1</div>
    </div>
    <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
    <div class="ovdTable__tableContent">  
        <!-- flex:1 1 auto; -->
        <div class="ovdTable__column">   
            <!-- 1-n -->
            <div class="ovdTable__cell">                 
        </div>
    </div>
</div>

第1栏

我已更新代码笔以匹配解决方案。

请将解决方案保留在答案部分。我不知道你为什么删除了你写的答案并将其包含在问题中,但问题不应该包含答案。我建议取消删除您的答案,并将其标记为已接受的答案。
<!-- display: flex;flex-flow: column nowrap; flex:1 1 auto; --> 
<div class="ovdTable"> 
    <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
    <!-- position: sticky; top:0px; z-index:2; --> 
    <div class="ovdTable__tableHeader"> 
      <!-- 1-n -->
      <div class="ovdTable__tableHeader--column">Column 1</div>
    </div>
    <!-- display: flex; flex-flow: row nowrap; flex: 1 1 auto; -->
    <div class="ovdTable__tableContent">  
        <!-- flex:1 1 auto; -->
        <div class="ovdTable__column">   
            <!-- 1-n -->
            <div class="ovdTable__cell">                 
        </div>
    </div>
</div>