小编Jgo*_*731的帖子

固定宽度为100%的位置忽略了主体填充

我试图制作一个跨越页面宽度减去10px左右的页脚.我试图通过在10px的所有侧面给身体填充来做到这一点.在下面的代码中,标题工作正常,但页脚忽略右侧的主体填充.为什么这样做,我该如何解决?

<!DOCTYPE html>
<html>
    <head>
        <style>
            div {
                padding:0;
                margin:0;
            }
            body {
                margin: 0;
                padding: 0 10px;
            }
            #header {
                height: 150px;
                width: 100%;
                margin: 0 auto;
                background: #333;
            }
            #footer {
                position: fixed;
                bottom: 5px;
                width: 100%;
                background: #f63;
                text-align: center;
            }
        </style>
    </head>
    <body>
        <div id="header"></div>
        <div id="footer">I am the footer!</div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

html css

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

css ×1

html ×1