【问题标题】:Is it possible to apply position: sticky to <thead> or <tr> element?是否可以应用 position: sticky to <thead> 或 <tr> 元素?
【发布时间】:2015-05-03 17:23:20
【问题描述】:

是否可以将position: sticky 应用到&lt;thead&gt; 或第一个&lt;tr&gt; 标签以使表格标题在滚动表格主体时卡在视口顶部?

【问题讨论】:

    标签: css css-position html-table sticky


    【解决方案1】:

    是的,可以将position: sticky 应用于theadtr 元素。 position property 可以应用于

    除 table-column-group 和 table-column 之外的所有元素

    但不,它不会像你想要的那样表现:

    position: sticky对表格元素的影响与for相同 position: relative

    【讨论】:

      【解决方案2】:

      specification 摘要明确指出:

      其他类型的布局,例如表格、“浮动”框、ruby 注释、网格布局、列和普通“流”内容的基本处理,在其他模块中进行了描述。

      【讨论】:

      • 注意这意味着CSS Positioning 没有标准化表格布局。但它标准化了元素的定位和堆叠,包括表格元素。
      猜你喜欢
      • 2013-04-07
      • 2012-09-20
      • 2023-03-05
      • 1970-01-01
      • 2023-02-01
      • 2017-08-05
      • 1970-01-01
      • 2018-02-09
      • 2018-12-09
      相关资源
      最近更新 更多