Realized by css - let the footer of the page always be at the bottom

When the page content is full, slide to the bottom and display the footer at the bottom;
when the page content is not full, the footer is also displayed at the bottom.
The specific implementation code is as follows:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			* {
      
      
				margin: 0;
				padding: 0;
			}

			html,
			body {
      
      
				height: 100%;
			}

			.page {
      
      
				display: flex;
				flex-direction: column;
				height: 100%;
			}

			header {
      
      
				background: green;
				flex: 0 0 auto;
			}

			.content {
      
      
				background: #ccc;
				flex: 1 0 auto;
			}

			footer {
      
      
				background: green;
				flex: 0 0 auto;
			}
		</style>
	</head>
	<body>
		<body>
			<div class="page">
				<header> 头部 </header>
				<div class="content">
					这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!这是内容区域!!
				</div>
				<footer> 底部 </footer>
			</div>
		</body>
	</body>
</html>

Guess you like

Origin blog.csdn.net/weixin_48596030/article/details/131735195