CSS - 水平滚动上的粘性 div? [英] CSS - Sticky div on horizontal scroll?

查看:29
本文介绍了CSS - 水平滚动上的粘性 div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含如下表单的 div:

I have a div containing a form like this:

下面的结果表很宽,需要横向滚动.

The results table below is very wide, so horizontal scroll is needed.

如何使表单 div 具有粘性,以便在水平滑动时在结果上方,表单保持在顶部?

How can I make the form div sticky so that when I horizontally scoll over the results the form stays on the top?

只找到关于带有 position:sticky 的垂直滚动的文档,但没有找到关于水平滚动的文档.欢迎提出任何建议.

Only found documentation on vertical scroll with position:sticky, but nothing about horizontal scroll. Any advice will be welcome.

推荐答案

尝试使用类名包装器或您想要的任何名称将表格包装在 div 中,并添加以下样式:

try to wrap the table in the div with class name wrapper or any name you want and add these styles:

.wrapper { 
  width: 100vw;
  overflow-x: scroll;
}

这篇关于CSS - 水平滚动上的粘性 div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆