css浮动页脚边距

发布于 2024-09-13 05:42:16 字数 1170 浏览 9 评论 0原文

我正在尝试修改粘性页脚(http://www.cssstickyfooter.com/)以显示边距...对于宽度:90%和边距:自动的左右来说很容易

| |    | |
| |    | |
| |    | |
| |    | |

,但是如何将高度达到90%(或显示某种顶部和底部边距)而不弄乱浮动页脚,

|  ____  |
| |    | |
| |____| |
|        |

谢谢

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,
textarea,p,blockquote,th,td { 
    margin:0;
    padding:0;
}
#header {
    height: 33px;
    line-height: 33px;
    text-align: center;
    background-color: green;
}
html { height: 100%; }
body { height: 100%; width: 90%; margin: auto; }
#wrap { min-height: 100%; background-color:gray; }
#main {
    overflow: auto;
    padding-bottom: 33px; /* must be same height as the footer */
    background-color: red;
    height: 100%;
}
#footer {
    position: relative;
    margin-top: -33px; /* negative value of footer height */
    height: 33px;
    line-height: 33px;
    text-align: center;
    background-color:blue;
}
​

http://jsfiddle.net/56REF/

i am trying to modify a sticky footer (http://www.cssstickyfooter.com/) to show a margin... it is easy for right and left with width:90% and margin:auto

| |    | |
| |    | |
| |    | |
| |    | |

but how to get the height to 90% (or show some kind of top & bottom margin) without messing up the floating footer

|  ____  |
| |    | |
| |____| |
|        |

thanks

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,
textarea,p,blockquote,th,td { 
    margin:0;
    padding:0;
}
#header {
    height: 33px;
    line-height: 33px;
    text-align: center;
    background-color: green;
}
html { height: 100%; }
body { height: 100%; width: 90%; margin: auto; }
#wrap { min-height: 100%; background-color:gray; }
#main {
    overflow: auto;
    padding-bottom: 33px; /* must be same height as the footer */
    background-color: red;
    height: 100%;
}
#footer {
    position: relative;
    margin-top: -33px; /* negative value of footer height */
    height: 33px;
    line-height: 33px;
    text-align: center;
    background-color:blue;
}
​

http://jsfiddle.net/56REF/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

允世 2024-09-20 05:42:16

这适合您的需求吗?
http://jsfiddle.net/CZayc/

would this suit your needs?
http://jsfiddle.net/CZayc/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文