0

很抱歉这个愚蠢的问题,但出于某种原因,HTML/CSS 布局的这一部分总是让我...

我在http://kdmalikdesign.com/test/LinguisticPeers/index.html有一个网站。只是练习 HTML/CSS/jQuery 和最终的 PHP/数据库。

在 chrome 中,页脚最终会太长。在 Firefox 中,页脚大约是我想要的页脚的三倍,在 Safari 中也是如此。现在我在 html 和 body 上有 100% 的高度,以便背景图像扩展到显示的所有内容。

为了补偿页脚(现在太长),我是否必须将主容器设置为最小长度,以便页脚可以容纳空间?对此有一般的设计规则吗?还是 CSS 规则?

基本上发生的事情是我喜欢页眉和主容器的外观,但由于它没有填满整个浏览器窗口,它最终会使页脚太长,或者如果 html,body 100% 不存在,就会变成一个页脚下方的空白区域。如果您想快速检查它,我的 CSS 代码如下。

html,body 上唯一的高度是 100%。Header 的高度为 100px,每个容器为 160px。页脚也是 55px。

html, body, div, header, footer, article, h2 {
    margin: 0px;
    padding: 0px;
}

html, body {
    height: 100%;
    background-image: url('images/bkg-img.jpg');
    background-repeat: repeat;
}
header {
background: #6888fd; /* Old browsers */
background: -moz-linear-gradient(top, #6888fd 0%, #1c46e9 55%, #0330e4 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6888fd), color-stop(55%,#1c46e9), color-stop(100%,#0330e4)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6888fd 0%,#1c46e9 55%,#0330e4 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6888fd 0%,#1c46e9 55%,#0330e4 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6888fd 0%,#1c46e9 55%,#0330e4 100%); /* IE10+ */
background: linear-gradient(to bottom, #6888fd 0%,#1c46e9 55%,#0330e4 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6888fd', endColorstr='#0330e4',GradientType=0 ); /* IE6-9 */
height: 100px;
}

#background-container {
    padding-top: 50px;
    padding-bottom: 25px;
}

#container {
    margin: 0 auto;
    background-color: #587DFF;
    height: 230px;
    width: 830px;

    text-align: center;
    padding-top: 100px;

    -moz-border-radius: 25px;
    border-radius: 25px;
}

#article-container {
    width: 960px;
    margin: 0 auto;
}

article {
    border: 4px solid #9AADFA;
    background-color: #002DE2;
    color: #fff;
    width: 280px;
    height: 160px;

    float: left;
    margin-left: 30px;
    margin-top: 25px;
    /* 
            display:-moz-inline-stack;
display:inline-block;
zoom:1;
*display:inline;
    */
}

.clear {
    clear: both;
}

span {
    display: block;
    padding-top: 10px;
    color: #6D8EFF;
}

h2 {
    padding-left: 10px;
    padding-top: 5px;
}

p {
    padding-left: 5px;
    padding-right: 5px;
}

footer {
    text-align: center;
    border-top: 1px solid #7493FF;
    background-image: url('images/bkg-img.jpg');
    background-repeat: repeat;

    height: 55px;
}

nav {
    float: right;
    color: #84A0FF;
    position: relative;
    top: 60px;
    left: -75px;
}

nav ul {
    list-style-type: none;
}

nav ul li {
    display: inline;
    padding-left: 10px;
}

#login-container {
    float: right;
    padding-right: 50px;
    padding-top: 25px;
    color: #fff;
    position: relative;
    left: 450px;
}

#header-container {
margin: 0 auto;
    width: 960px;
    height: 100px;
}
4

1 回答 1

0

如果您希望页脚贴在页面底部,类似这样的操作可能会有所帮助。

于 2013-02-02T22:25:43.110 回答