页面无滚动条,里面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>
相关推荐
程序员大阳1 小时前
副队长HTML+CSS博客网站实战 (3)–首页主体:Grid 文章卡片 + 侧边栏布局
css·html·侧边栏·博客网站·首页·文章卡片
西索斯coding2 小时前
Claude Code 工具调用返回空怎么办?claude-opus-5.5 的 input_schema 校验踩坑记录与修复方案
服务器·前端·javascript·ai
程序员Sunday2 小时前
Flex 和 Grid 有什么区别?一维布局、二维布局怎么选?
前端·css·面试
Jlzn88882 小时前
华南PACK线自动化率怎么统计才靠谱
前端·javascript·自动化
Hilaku2 小时前
ERP选型时不问MCP,等于默认三年后再付一次集成费!
前端·javascript·程序员
爱喝水的小周2 小时前
实验十一 Vuex 实现王者荣耀后台比赛管理系统
前端·css·html
三十而立洋2 小时前
前端模块化的演进:从全局变量到 Import Maps
前端·javascript·前端工程化
橘猫走江湖2 小时前
浮动塌陷复现失败:父元素为什么一直不塌
前端·css
小凯在掘金2 小时前
一文搞懂 Map、Set、WeakMap、WeakSet
javascript·面试
用户1733598075372 小时前
纯前端 PDF 按书签拆分避坑指南:拆分后章节对不上?
前端·javascript·vue.js