当前位置:网站首页>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 .
边栏推荐
- std::shared_ ptr initialization: make_ shared&lt; Foo&gt; () vs shared_ ptr&lt; T&gt; (new Foo) [duplicate]
- Market trend report, technical innovation and market forecast of taillight components in China
- I let the database lock the table! Almost fired!
- China Indonesia adhesive market trend report, technological innovation and market forecast
- Hair growth shampoo industry Research Report - market status analysis and development prospect forecast
- Recommend 10 excellent mongodb GUI tools
- How to contribute to the source code of ongdb core project
- NoSQL之readis配置与优化(终章)
- Communication mode based on stm32f1 single chip microcomputer
- [Chongqing Guangdong education] National Open University spring 2019 1248 public sector human resource management reference questions
猜你喜欢
@EnableAspectAutoJAutoProxy_ Exposeproxy property
What should ABAP do when it calls a third-party API and encounters garbled code?
函數式接口,方法引用,Lambda實現的List集合排序小工具
Hidden communication tunnel technology: intranet penetration tool NPS
Software Engineer vs Hardware Engineer
AI system content recommendation issue 24
Preliminary practice of niuke.com (10)
overflow:auto与felx结合的用法
[North Asia data recovery] a database data recovery case where the partition where the database is located is unrecognized due to the RAID disk failure of HP DL380 server
Qt---error: ‘QObject‘ is an ambiguous base of ‘MyView‘
随机推荐
程序员怎么才能提高代码编写速度?
The vscode waveform curve prompts that the header file cannot be found (an error is reported if the header file exists)
Use and principle of thread pool
Understand asp Net core - Authentication Based on jwtbearer
[Previous line repeated 995 more times]RecursionError: maximum recursion depth exceeded
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
Laravel simply realizes Alibaba cloud storage + Baidu AI Cloud image review
Research Report on market supply and demand and strategy of tetramethylpyrazine industry in China
Research Report on market supply and demand and strategy of China's plastics and polymer industry
China's plastic processing machinery market trend report, technological innovation and market forecast
Interface fonctionnelle, référence de méthode, Widget de tri de liste implémenté par lambda
Recommend 10 excellent mongodb GUI tools
QT graphical view frame: element movement
What is torch NN?
Socks agent tools earthworm, ssoks
Interpretation of the champion scheme of CVPR 2020 night target detection challenge
时钟轮在 RPC 中的应用
Research Report on plastic recycling machine industry - market status analysis and development prospect forecast
同构图与异构图CYPHER-TASK设计与TASK锁机制
高度剩余法