18910140161

如何下移页眉和页脚中的内容?

顺晟科技

2021-09-01 12:02:06

102

我试图在所有css类中使用边距底部来向下移动页眉和页脚中的内容,但仍然无法工作。请看图像来理解我的意思。CSS初学者在这里!我在下面包括html和css代码,并在css中评论了我试图插入边距的地方。谢谢。

   Please do help me see where I can insert margin-bottom so as my content in header and 
   footer can be shifted down a little 

 /* 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;
    }
/* I have tried to put margin-bottom here but it does not work */
    .container{
        width: 80%;
        margin: 0 auto; /* Center the DIV horizontally */
        text-align: center;
    }
/* I have tried to put margin-bottom here but it does not work */
    .fixed-header, .fixed-footer{
        width: ;
        height: 100px;
        position: fixed;        
        background: #333;
        padding: 10px 0;
        color: #fff;
        font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
        font-weight: bold;
    }
    .fixed-header{
        top: 0;
    }
    .fixed-footer{
        bottom: 0;
    }    
    /* Some more styles to beutify this example */
/* I have tried to put margin-bottom here but it does not work */
    nav a{
        color: #fff;
        text-decoration: none;
        padding: 10px 30px;
        display: inline-block;
    }
    .container p{
        line-height: 200px; /* Create scrollbar to test positioning */
        
    }
<!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"> <link rel="stylesheet" href="css/style.css"> <title>Your Name Goes Here</title> <style> </style> </head> <body> <div class="fixed-header"> <div class="container"> <nav> <a href="#">Home</a> <a href="#">About Me</a> <a href="#">Gallery</a> <a href="#">Music & Videos</a> <a href="#">School</a> </nav> </div> </div> <div class="container"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante. Vestibulum id metus ac nisl bibendum scelerisque non non purus. Suspendisse varius nibh non aliquet sagittis. In tincidunt orci sit amet elementum vestibulum. Vivamus fermentum in arcu in aliquam. Quisque aliquam porta odio in fringilla. Vivamus nisl leo, blandit at bibendum eu, tristique eget risus. Integer aliquet quam ut elit suscipit, id interdum neque porttitor. Integer faucibus ligula.</p> </div> <div class="fixed-footer"> <div class="container">Copyright &copy; 2021 by @travelynn</div> </div> </body> </html>


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航