全尺寸<main>,页脚被推到底部

时间:2017-04-30 14:05:32

标签: html css html5 css3 web

我的页面分为3个部分。 public async Task<ItemPreview> Method2(object body) { var response = await Method1("..", body ); return await response.Content.ReadAsAsync<ItemPreview>(); } <header><main>

<footer>固定在顶部,为109px,其6px边框为高,因此<header>的边距为109px。

我希望<main>扩展到<main>下方的整个页面以及<header>,如果没有可用于推送它的内容,则应放在底部即使没有内容扩展<footer>放置背景图片的大小,屏幕和<main>也应扩展到<footer>

<main>为86px高,因为它是80px,顶部边框为6px。

要推迟<footer>,我必须在正文上设置<footer>,但要在min-hight: 100%;上设置全屏背景图片,我必须设置<main>然后在滚动之前,页脚停留在屏幕底部的位置。

如何解决此问题?

height: 100%;
html {
  height: 100%;
  box-sizing: border-box;
}

body {
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
  position: relative;
  height: 100%;
  /* or min-hight: 100% */
}

#in {
  width: 1000px;
  margin-left: auto;
  margin-right: auto;
  height: 100%;
}


/* ---------------------------------------------------------------- */

#all {
  height: 100%;
}

#fullmain {
  padding-top: 109px;
  padding-bottom: 86px;
  text-align: center;
  background: #f5f5f5 url(" http://pre06.deviantart.net/2bf3/th/pre/i/2010/284/b/d/autumn_fortest_ii_by_lotusonlinede-d30jn9b.jpg") no-repeat center center;
  background-size: cover;
  min-height: 100%
}

#header {
  background-color: #25211e;
  border-bottom: 6px solid #1d1a18;
  text-align: center;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 103px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  z-index: 99;
}

#heading {
  font-family: "titlefont";
  color: #c1b497;
  font-size: 45px;
  display: inline-block;
  margin-bottom: 10px;
  margin-top: 15px;
}


/* ---------------------------------------------------------------- */

#footer {
  background-color: #25211e;
  border-top: 6px solid #1d1a18;
  text-align: center;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 80px;
  z-index: 98;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

#credit {
  font-family: "Helvetica";
  font-size: 14px;
  color: #c1b497;
  font-weight: 600;
}

1 个答案:

答案 0 :(得分:0)

这是你在找什么?你的问题不明确。

html {
  height: 100%;
  box-sizing: border-box;
}

body {
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
  position: relative;
  height: 100%;
  /* or min-hight: 100% */
}

#in {
  width: 1000px;
  margin-left: auto;
  margin-right: auto;
  height: 100%;
}


/* ---------------------------------------------------------------- */

#all {
  height: 100%;
}

#fullmain {
  padding-top: 109px;
  padding-bottom: 86px;
  text-align: center;
  background: #f5f5f5 url(" http://pre06.deviantart.net/2bf3/th/pre/i/2010/284/b/d/autumn_fortest_ii_by_lotusonlinede-d30jn9b.jpg") no-repeat center center;
  background-size: cover;
  height: calc(100% - 195px);
}

#header {
  background-color: #25211e;
  border-bottom: 6px solid #1d1a18;
  text-align: center;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 103px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  z-index: 99;
}

#heading {
  font-family: "titlefont";
  color: #c1b497;
  font-size: 45px;
  display: inline-block;
  margin-bottom: 10px;
  margin-top: 15px;
}


/* ---------------------------------------------------------------- */

#footer {
  background-color: #25211e;
  border-top: 6px solid #1d1a18;
  text-align: center;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 80px;
  z-index: 98;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
}

#credit {
  font-family: "Helvetica";
  font-size: 14px;
  color: #c1b497;
  font-weight: 600;
}
<div id="all">
  <header id="header">
    <h1 id="heading">My Page</h1>
  </header>
  <main id="fullmain">

  </main>
  <footer id="footer">
    <p id="credit">Footer</p>
  </footer>
</div>