<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
footer {
width: 100%;
height: 50px;
background-color: antiquewhite;
/* 固定定位 */
position: fixed;
left: 0;
bottom: 0;
z-index: 5;
}
footer p {
line-height: 50px;
text-align: center;
}
</style>
</head>
<body>
<!-- 底部的写法 -->
<footer>
<p>利用固定定位把底部固定在浏览器的底部</p>
</footer>
</body>
</html>
固定定位:
元素的位置相对于浏览器窗口是固定位置,即固定在在浏览器上,即使窗口是滚动的它也不会移动 Fixed定位使元素的位置与文档流无关,因此不占据空间。