页面无滚动条,里面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>
相关推荐
gnip1 小时前
总结一期正则表达式
javascript·正则表达式
爱分享的程序员1 小时前
前端面试专栏-算法篇:18. 查找算法(二分查找、哈希查找)
前端·javascript·node.js
翻滚吧键盘1 小时前
vue 条件渲染(v-if v-else-if v-else v-show)
前端·javascript·vue.js
你这个年龄怎么睡得着的1 小时前
为什么 JavaScript 中 'str' 不是对象,却能调用方法?
前端·javascript·面试
南屿im1 小时前
JavaScript 手写实现防抖与节流:优化高频事件处理的利器
前端·javascript
西陵2 小时前
Nx带来极致的前端开发体验——借助CDD&TDD开发提效
前端·javascript·架构
叹一曲当时只道是寻常2 小时前
vue中添加原生右键菜单
javascript·vue.js
旷世奇才李先生2 小时前
Next.js 安装使用教程
开发语言·javascript·ecmascript
Mintopia4 小时前
四叉树:二维空间的 “智能分区管理员”
前端·javascript·计算机图形学
慌糖4 小时前
RabbitMQ:消息队列的轻量级王者
开发语言·javascript·ecmascript