Javascript 如何使网页中的表格垂直滚动,同时使其他所有内容固定到位

Javascript 如何使网页中的表格垂直滚动,同时使其他所有内容固定到位,javascript,jquery,html,css,scroll,Javascript,Jquery,Html,Css,Scroll,我想用鼠标滚动事件垂直滚动网页中的一个特定表格,同时将包括背景图像在内的所有内容固定到位 这是我的表格css脚本 @media screen and (min-width: 480px) { table{ background-color: rgba(255, 255, 0, 0.7); text-align: center; font-family: opensans;

我想用鼠标滚动事件垂直滚动网页中的一个特定表格,同时将包括背景图像在内的所有内容固定到位

这是我的表格css脚本

@media screen and (min-width: 480px) {
            table{
              background-color: rgba(255, 255, 0, 0.7);
              text-align: center;
              font-family: opensans;
              font-size: 20px;
              color: rgba(0, 0, 0, 255);
              width: 70vw;
              height: 100px;
              overflow-y: scroll;
              overflow-x: hidden;
            }
          }
这是背景和标题的脚本

body{
            background-color: rgba(0, 0, 0, 255);
            background: url("background.jpg");
            background-position: 49% 20%;
            background-repeat: no-repeat;
            background-blend-mode: luminosity;
          }

.Header{
            font-family: Neon;
            font-size: 40px;
            position: fixed;
            letter-spacing: 1px;
            top: 0;
            left: 0;
            width: 100%;
            line-height: 35px;
            text-align: center;
            color: rgb(255, 0, 0);
          }
不幸的是,页眉仍然固定在它的位置上,但是页面的背景不是。我尝试添加如下固定的背景位置

body{
            background-color: rgba(0, 0, 0, 255);
            background: url("background.jpg");
            background-position: fixed;
            background-repeat: no-repeat;
            background-blend-mode: luminosity;
          }

但滚动时背景仍会向上(垂直滚动)

使用
overflow-y:auto
将表格包装在div中,并将
div
的高度设置为,例如,
100px
使用
overflow-y:auto
将表格包装在div中,并将
div
的高度设置为,例如,
100px

添加
要固定的背景附件。
检查下面的代码片段

body {
    background-image: url("img_tree.gif");
    background-repeat: no-repeat;
    background-attachment: fixed;
   }

添加要修复的
背景附件。
检查下面的代码片段

body {
    background-image: url("img_tree.gif");
    background-repeat: no-repeat;
    background-attachment: fixed;
   }

你的
主体之所以会滚动,是因为它对于窗口来说太大了。使内容小于窗口,则正文不会滚动。然后使内容本身可滚动。你的
正文
滚动的原因是它对于窗口来说太大了。使内容小于窗口,则正文不会滚动。然后使内容本身可滚动。