当前位置:网站首页>Overflow: the combination of auto and Felx
Overflow: the combination of auto and Felx
2022-07-04 16:45:00 【Elephants and ants】
overflow:auto; If the content is trimmed , The browser will display a scroll bar , To see the rest .
flex Properties in
display: flex;
flex-direction: column; The principal axis is perpendicular , The starting point is at the top .
1、overflow and flex Layout collocation
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>overflow:auto Usage of </title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<style type="text/css">
html,body{
width: 100%;
height: 100%;
}
.container{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.header{
width: 100%;
height: 100px;
background: #f99;
}
.content{
width: 100%;
height: 100%;
overflow: auto;
background: yellow;
flex: 1;
}
.footer{
width: 100%;
height: 100px;
background: #99f;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
</div>
<div class="content">
<ul>
<li>111111</li>
<li>111111</li>
<li>111111</li>
<li>111111</li>
<li>111111</li>
<li>111111</li>
<li>111111</li>
<li>111111</li>
there li Write more , This will show the effect , I'm here to save space .
</ul>
</div>
<div class="footer">
</div>
</div>
</body>
</html>
To achieve overflow: auto; This effect , First, layout , Then write the style .
The outermost parent box in the style container, Add the following style :
.container{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
Also, you must give html and body Give width and height 100%;
html,body{
width: 100%;
height: 100%;
}
The head and bottom are given a fixed height , General app The head and bottom of the are fixed , Like wechat chat record .
.header{
width: 100%;
height: 100px;
background: #f99;
}
.footer{
width: 100%;
height: 100px;
background: #99f;
}
In the middle of the content Given flex:1, And add our protagonist overflow:auto; Excess content is automatically cropped .
.content{
width: 100%;
height: 100%;
overflow: auto;
background: yellow;
flex: 1;
}
The renderings are as follows :
The middle content area can slide up and down , The excess part is automatically cropped .
边栏推荐
- Principle and general steps of SQL injection
- Overview of convolutional neural network structure optimization
- Hair growth shampoo industry Research Report - market status analysis and development prospect forecast
- ~89 deformation translation
- Sequence diagram data modeling and industrial chain analysis
- QT graphical view frame: element movement
- 程序员怎么才能提高代码编写速度?
- Market trend report, technical innovation and market forecast of electrochromic glass and devices in China and Indonesia
- Interface test - knowledge points and common interview questions
- 多年锤炼,迈向Kata 3.0 !走进开箱即用的安全容器体验之旅| 龙蜥技术
猜你喜欢
Vscode setting outline shortcut keys to improve efficiency
Anta is actually a technology company? These operations fool netizens
Game theory
QT graphical view frame: element movement
Understand the rate control mode rate control mode CBR, VBR, CRF (x264, x265, VPX)
Position encoding practice in transformer
Cut! 39 year old Ali P9, saved 150million
What is torch NN?
Opencv learning -- geometric transformation of image processing
Common knowledge of unity Editor Extension
随机推荐
A trap used by combinelatest and a debouncetime based solution
同构图与异构图CYPHER-TASK设计与TASK锁机制
DC-2靶场搭建及渗透实战详细过程(DC靶场系列)
Intranet penetrating FRP: hidden communication tunnel technology
力扣今日题-1200. 最小绝对差
Market trend report, technical innovation and market forecast of taillight components in China
The content of the source code crawled by the crawler is inconsistent with that in the developer mode
ECCV 2022放榜了:1629篇论文中选,录用率不到20%
Talking about Net core how to use efcore to inject multiple instances of a context annotation type for connecting to the master-slave database
Redis: SDS source code analysis
Feature extraction and detection 15-akaze local matching
Vscode setting outline shortcut keys to improve efficiency
嵌入式软件架构设计-函数调用
一图看懂ThreadLocal
std::shared_ ptr initialization: make_ shared&lt; Foo&gt; () vs shared_ ptr&lt; T&gt; (new Foo) [duplicate]
Interface fonctionnelle, référence de méthode, Widget de tri de liste implémenté par lambda
Can I "reverse" a Boolean value- Can I 'invert' a bool?
高度剩余法
PR FAQ: how to set PR vertical screen sequence?
Model fusion -- stacking principle and Implementation