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
This article shares the specific code for using j...
mysql dirty pages Due to the WAL mechanism, when ...
html Copy code The code is as follows: <SPAN cl...
MySQL official website: https://www.mysql.com/dow...
1. Elements and tags in HTML <br />An eleme...
Closures are one of the traditional features of p...
My machine environment: Windows 2008 R2 MySQL 5.6...
Table of contents 1. View the tables in the curre...
1. Introduction Containers use a sandbox mechanis...
This article shares the specific code of jQuery t...
With the right settings, you can force Linux user...
I used Vue.js to make a nine-grid image display m...
Table of contents Styles in uni-app Summarize Sty...
This article example shares the specific code of ...
Execute the following command to report an error ...