【问题标题】:stick content at the bottom of the page将内容粘贴在页面底部
【发布时间】:2017-05-09 18:56:29
【问题描述】:

我的问题:

我设计了单页。页眉、内容(部分和旁边)和页脚。

页脚和页眉是粘性的。

我希望内容贴在页尾和页脚上方。

请指导我。

【问题讨论】:

标签: css sticky sticky-session


【解决方案1】:

你是在暗示这样的事情吗?在这个例子中。无论屏幕尺寸如何,您的内容都将始终停留在页脚上,即使其中只有一行。

*{
  box-sizing: border-box;
}
body, html{
  height: 100%;
  width: 100%;
  margin: 0;
}
body{
  display:flex;
  flex-direction: column;
}
#container
{
    margin: 0 auto;
    width:90%;
    background-color: white;
    border: 2px solid black;
    flex-shrink:0;
    flex-grow:1;
    display:flex;
}
.header,.footer
{
    margin: 0 auto;
    width:100%;
    text-align: center;
    height:1.5em;
    background-color: white;
    border: 1px solid black;
    flex-shrink:0;
    background-color:green;
  color:white;
}
.col {
    height:90%;
    flex-shrink:0;
    flex-grow:1;
    margin:0 2% 0 2%;
}
<div class="header">
  Header here
</div>
<div id="container">
  <div class="col">
    test column 1
    <p>
    Content
    </p>
    <p>
    Content
    </p>
    <p>
    Content
    </p>
  </div>
  <div class="col">
    test column 2
    <p>
    Content
    </p>
    <p>
    Content
    </p>
    <p>
    Content
    </p>
  </div>
</div>
<div class="footer">
Footer Here
</div>

【讨论】:

  • 嗨,对不起,你能帮我把'section'元素和'sidebar'的内容也粘贴到页面底部吗?!
猜你喜欢
  • 2016-07-11
  • 1970-01-01
  • 2014-11-09
  • 1970-01-01
  • 2012-08-20
  • 1970-01-01
  • 2011-10-15
相关资源
最近更新 更多