页面无滚动条,里面div各自有滚动条

一、双滚动条左右布局

实现效果

实现代码

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body,
      html {
        padding: 0;
        margin: 0;
      }

      .father {
        display: flex;
        flex: 1;
        overflow: hidden;
      }
      .left {
        flex: 1;
        background-color: red;
        max-height: 100vh;
        overflow-y: scroll;
      }
      .right {
        width: 300px;
        background-color: green;
        max-height: 100vh;
        overflow-y: scroll;
      }

      .ceshi {
        width: 100px;
        height: 100px;
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="left">
        left
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
      </div>
      <div class="right">
        right
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
        <div class="ceshi">111</div>
      </div>
    </div>
  </body>
</html>

二、双滚动条上下布局

实现效果

实现代码

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      html,
      body {
        margin: 0;
        padding: 0;
      }
      .father {
        display: flex;
        width: 100%;
        flex-direction: column;
        overflow: hidden;
      }

      .top {
        height: 50px;
        background-color: aqua;
      }
      .content {
        flex: 1;
        max-height: calc(100vh - 50px);
        background-color: blueviolet;
        overflow-y: scroll;
      }
      .test {
        width: 100px;
        height: 100px;
        border: 1px solid red;
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="top">111</div>
      <div class="content">
        content
        <div class="test">test</div>
        <div class="test">test</div>
        <div class="test">test</div>
        <div class="test">test</div>
        <div class="test">test</div>
        <div class="test">test</div>
      </div>
    </div>
  </body>
</html>
相关推荐
初遇你时动了情15 分钟前
ts 泛型
javascript·react.js·typescript
EndingCoder2 小时前
React从基础入门到高级实战:React 生态与工具 - React 单元测试
前端·javascript·react.js·typescript·单元测试·前端框架
年纪轻轻只想躺平3 小时前
Vue2部分知识点和注意项
前端·javascript·vue.js
多则惑少则明4 小时前
Vue开发系列——Vue 生命周期钩子 及常见知识点
前端·javascript·vue.js·前端框架
菥菥爱嘻嘻5 小时前
JS手写代码篇---Pomise.race
开发语言·前端·javascript
CodeCipher6 小时前
前端Vue3列表滑动无限加载实现
前端·javascript·vue.js·vue
十碗饭吃不饱7 小时前
vue修改配置文件.env.development不生效
前端·javascript·vue.js
二十雨辰9 小时前
[CSS3]vw/vh移动适配
前端·css·css3
软件开发技术深度爱好者9 小时前
用HTML5+JavaScript实现汉字转拼音工具
前端·javascript·html5
烂笔头儿@11 小时前
vue 实现table上下拖拽行功能
前端·javascript·vue.js