【问题标题】:how place large sized footer div below small sized main-container div如何将大型页脚 div 放在小型主容器 div 下方
【发布时间】:2015-04-04 10:02:52
【问题描述】:

我有宽度为 1000px 的标题和主容器 div 并且相对定位。在此之下,我需要一个宽度为 1300 像素的页脚,但如果我将其相对定位,它将变为 1000 像素,如果我将其定位固定,它不会在主容器下方居中。希望你能得到我的Q。 代码细节是:

.main-header {
    position: relative;
    margin: 0 auto;
    width: 100%;
    z-index: 99;
    max-width: 1000px;
    float: none;
    display: block;
    min-height:145px;
    border-bottom:none;
}
.main-container {
    width: 1000px;
    margin: 0 auto;
    overflow: hidden;
    padding: 0;
    background: #fff;
    position: relative;
    box-shadow: 0px 0px 10px rgba(50, 50, 50, 0.17);
}

.copyrights {
    float:left;
    width:1300px;
    height:285px;
    clear: both;
    background: #7e8285;
    padding: 0 0 0 0;
    margin-top: 0px;
    margin-left:auto;
    margin-right:auto;
    color: #d3d4d6;
    font-size: 14px;
    text-transform:capitalize;
    position: relative;
    border-top:none;
    z-index:1;
}

/copyrights 是为页脚区域定义的一个类。/ 我想要页眉,主容器宽度为 1000 像素,页脚宽度为 1300 像素。

【问题讨论】:

  • 请将所有相关代码发布到您的问题 (html)
  • 我什至不确定要问什么以及期望的行为是什么

标签: html css header containers footer


【解决方案1】:

尝试将您的体型定义为 1300 像素。这听起来像问题。我刚刚编码,它非常适合我。

body {
    width: 1300px;
}

.main-header {
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 1000px;
    float: none;
    display: block;
    min-height: 145px;
    border-bottom: none;
    background-color: #F70B0F;
}
.main-container {
    width: 1000px;
    margin: 0 auto;
    overflow: hidden;
    padding: 0;
    background-color: #1532B5;
    position: relative;
    box-shadow: 0px 0px 10px rgba(50, 50, 50, 0.17);
}

.copyrights {
    float: left;
    width: 1300px;
    height: 285px;
    clear: both;
    background-color: #ACD2EF;
    padding: 0 0 0 0;
    margin-top: 0px;
    margin-left: auto;
    margin-right: auto;
    color: #d3d4d6;
    font-size: 14px;
    text-transform: capitalize;
    position: relative;
}

【讨论】:

  • 嗨,实际上它是一个 wordpress 主题中的样式表代码。经过彻底研究后,我发现主容器是一个包装类,其中有页眉和页脚。但主要问题是主容器宽度最初定义为 1000 像素,并且由于页脚是主容器的一部分,因此无法在 1000 像素宽度的主容器内添加 1300 像素宽度的页脚。这正是我所需要的。
  • 是的。和我想的一样。那么,您最终只是像我建议的那样增加了容器宽度以允许更大的页脚吗?很高兴你想出来了。你能加一个我的答案,这样我就可以提高我的声誉吗?
猜你喜欢
  • 2017-07-07
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
  • 2012-06-24
  • 2018-11-04
  • 1970-01-01
  • 2016-01-30
  • 1970-01-01
相关资源
最近更新 更多