<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>页脚固定在底部显示</title>
<style type="text/css">
*{
margin: 0;padding: 0;
}
html,body{height: 100%;}
#main{
height: auto;min-height: 100%;
}
#main .con{
padding-bottom: 150px;
}
#footer{
position: relative;height: 150px;
margin-top: -150px;clear: both;background: #ccc;
}
.clearfix:after{
content:".";
height: 0;
clear: both;
visibility: hidden;
}
.clearfix{
height:1%;/* Hides from IE-mac */ /*zoom:1*/
display: inline-block;
}
</style>
</head>
<body>
<div >

</div>
</body>
</html>

第二种:flex布局

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">

.Site {
display: flex;
min-height: 100vh;
flex-direction: column;
}
/*相对于viewport高度大小的文字*/
/*h1{font-size:8vh;}*/
/*如果视口的高度是200mm,那么上述代码中h1元素的字号将为16mm,即(8x200)/100*/
.Site-content {
flex: 1;
}

</style>
</head>
<body>

<body class="Site">
<header>...</header>
<main class="Site-content">...</main>
<footer>...</footer>
</body>
</body>
</body>
</html>

相关文章:

  • 2021-11-28
  • 2021-12-04
  • 2021-12-04
  • 2021-11-02
  • 2021-07-07
  • 2021-09-25
  • 2022-12-23
猜你喜欢
  • 2021-08-15
  • 2021-12-22
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案