欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
答:使用CSS固定定位
您可以使用CSS固定位置轻松创建粘性或固定的页眉和页脚。只需将CSSposition属性及其值fixed与topandbottom属性结合使用,即可将该元素相应地放置在视口的顶部或底部。
 
让我们看下面的示例,以了解其基本工作原理:
 
例试试这个代码»
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Implement Sticky Header and Footer with CSS</title>
<style>
    /* Add some padding on document's body to prevent the content
    to go underneath the header and footer */
    body{        
        padding-top: 60px;
        padding-bottom: 40px;
    }
    .fixed-header, .fixed-footer{
        width: 100%;

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h61106.shtml