Before starting the main text, I will introduce some uses of overflow and flex layout. The code is as follows: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Usage of overflow:auto</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> You need to write more li here so that the effect will be displayed. I do this here to save space. </ul> </div> <div class="footer"> </div> </div> </body> </html> To achieve the overflow: auto; effect, first layout and then write the style. .container{ width: 100%; height: 100%; display: flex; flex-direction: column; } Also, be sure to give html and body a width and height of 100%; html,body{ width: 100%; height: 100%; } The header and bottom have fixed heights. The header and bottom of general apps are fixed, like WeChat chat records. .header{ width: 100%; height: 100px; background: #f99; } .footer{ width: 100%; height: 100px; background: #99f; } The content in the middle is given flex: 1, and our main character overflow: auto is added; the content beyond that is automatically cropped. .content{ width: 100%; height: 100%; overflow:auto; background: yellow; flex: 1; } The effect diagram is as follows: The content area in the middle can be slid up and down, and the excess part is automatically cropped. This is the end of this article on the detailed usage of overflow:auto. For more relevant content on the usage of overflow:auto, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future! |
>>: Implementing form submission without refreshing the page based on HTML
Preface In the previous article Two data types in...
This article records the installation graphic tut...
You can save this logo locally as a .rar file and...
I encountered several problems when installing My...
Table of contents Preface Arrow Functions Master ...
Data cleaning (ETL) Before running the core busin...
This note is an installation tutorial. It has no ...
The default port number of the Windows server rem...
Preface: I recently started to study the construc...
This article records the installation and configu...
The default firewall of CentOS7 is not iptables, ...
1. Background of the incident: Because of work ne...
How to add a loading animation every time I scrol...
Table of contents Environment Setup Overview 1.Wh...
The <link> tag defines the relationship bet...