当前位置:网站首页>使用flex布局实现局部滚动条
使用flex布局实现局部滚动条
2022-07-17 23:15:00 【不负当下】
使用flex布局实现局部滚动条
高度定高 内容超出 滚动条不设置为整页而是在局部
原理
- 最外层
- 定高
- 设置flex布局
- 方向为column
- 需要设置滚动条的内容
- 外层设置为 flex :1
- 超出为 设置滚动条(overflow: auto)
- 必须设置子组件(超出的高度则会显示滚动条)
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style> body{
padding: 0; margin: 0; } .box {
height: 100vh; /* 高度占满屏幕 */ display: flex; flex-direction: column; overflow: hidden; /*让其不能超出 box的高度 */ } .top {
height: 200px; background: red; } .content {
flex: 1; /* box中剩余空间分配给content */ overflow: auto; /* 如果子内容超出的话利用滚动条 */ } .contentItem{
background: antiquewhite; height: 2000px; } </style>
<body>
<div class="box">
<div class="top"></div>
<div class="content">
<div class="contentItem"></div>
</div>
</div>
</body>
</html>
效果图
边栏推荐
- UVA - 12096 The SetStack Computer
- Notepad++ practical function sharing (regular line end line beginning replacement common methods, text comparison functions, etc.)
- 浅谈ISP-图像噪声模型2
- Leetcode 1296. 划分数组为连续数字的集合(提供一种思路)
- 微信小程序9-发布代码
- 解决jupyter控制台出现中文乱码的问题
- Cilium & Hubble
- 08_服务熔断Hystrix
- Redis高频面试题完整版
- CarMaker快速入门第四课开发48V P1混动系统
猜你喜欢

Google Earth engine - Classification and processing of UAV images

MMRotate从零开始训练自己的数据集

Li Hongyi machine learning 2022.7.15 -- gradient descent

2021牛客多校训练营5(B题)

Re understanding of Fourier transform

A - Trees on the level(树的层序遍历)

E. Split Into Two Sets(种类并查集+染色法判二分图)
![[code attached] how to realize handwritten digit recognition with hog+svm](/img/e1/870aec8bb75c7cf82dee62c68d1009.jpg)
[code attached] how to realize handwritten digit recognition with hog+svm

FPGA (VGA Protocol Implementation)
![2040: [蓝桥杯2022初赛] 砍竹子(优先队列)](/img/76/512b7fd4db55f9f7d8f5bcb646d9fc.jpg)
2040: [蓝桥杯2022初赛] 砍竹子(优先队列)
随机推荐
kibana 使用json文档数据
【用户文章】P4合并实践指南之实例拆解Resolve
Natural language processing model of bigscience open source bloom
08_服务熔断Hystrix
A - Trees on the level(树的层序遍历)
网上开户安全么?想知道证券公司开户如何得到优惠?
Cilium & Hubble
2036: [蓝桥杯2022初赛] 统计子矩阵(二维前缀和,一维前缀和)
初来乍到,多多关照(其实不是初来了^_^,Hello CSDN,我来了)
First try dart, notes
MySQL 安装
Google Earth engine - Classification and processing of UAV images
02-线性结构3 Reversing Linked List
C - matrix chain multiplexing (Application of stack)
线性表(顺序存储,链式存储)(带头结点的链表,不带头结点的链表)
N皇后问题(回溯法,排列树)
Leetcode 1275. 找出井字棋的获胜者
人脸技术:不清楚人照片修复成高质量高清晰图像框架(附源代码下载)
Redis high frequency interview questions full version
微信小程序7-云存储