Css 我的背景色位于页面底部,我希望在不滚动时页脚颜色填充底部

Css 我的背景色位于页面底部,我希望在不滚动时页脚颜色填充底部,css,background,footer,Css,Background,Footer,这里有一个例子 页面上的内容不多,所以它的高度很小。正文BG颜色甚至超过页脚都会填满页面底部-这看起来很可笑 当内容很小(用户屏幕上没有滚动条)时,如何使页脚颜色完成页面?我不想让每一页都有一个巨大的页脚,因为那会让人觉得可笑 谢谢。我会给正文和页脚相同的背景色,然后将“正文”背景色应用到正文本身内的包装器元素上 <!DOCTYPE html> <html> <head> <title>Alternative Background Me

这里有一个例子

页面上的内容不多,所以它的高度很小。正文BG颜色甚至超过页脚都会填满页面底部-这看起来很可笑

当内容很小(用户屏幕上没有滚动条)时,如何使页脚颜色完成页面?我不想让每一页都有一个巨大的页脚,因为那会让人觉得可笑


谢谢。

我会给正文和页脚相同的背景色,然后将“正文”背景色应用到正文本身内的包装器元素上

<!DOCTYPE html>
<html>
  <head>
    <title>Alternative Background Method</title>
    <style>
      body, 
      body > footer {
        background: /* bgcolor */
      }
      #content {
        background: /* original body background color */
      }
    </style>
  </head>
  <body>
    <section id="content">
      <!-- main content --->
    </section>
    <footer>
      <!-- footer contents -->
    </footer>
    <!--

      Any visible space between the bottom of the viewport and the 
      footer element will have the same background as the footer
      element itself.

    -->
  </body>
</html>

替代背景法
身体,
正文>页脚{
背景:/*bgcolor*/
}
#内容{
背景:/*原始车身背景色*/
}

我会给正文和页脚以相同的背景色,然后将“正文”背景色应用于正文本身中的包装器元素

<!DOCTYPE html>
<html>
  <head>
    <title>Alternative Background Method</title>
    <style>
      body, 
      body > footer {
        background: /* bgcolor */
      }
      #content {
        background: /* original body background color */
      }
    </style>
  </head>
  <body>
    <section id="content">
      <!-- main content --->
    </section>
    <footer>
      <!-- footer contents -->
    </footer>
    <!--

      Any visible space between the bottom of the viewport and the 
      footer element will have the same background as the footer
      element itself.

    -->
  </body>
</html>

替代背景法
身体,
正文>页脚{
背景:/*bgcolor*/
}
#内容{
背景:/*原始车身背景色*/
}

你能不能给主体赋予与页脚相同的背景色?不能,因为主体颜色大部分在页脚上方。然后我会遇到类似的问题。。。BF颜色填满了整个浏览器窗口,我的内容只有900-1000像素宽,大约。如果你有
FooFoo
,你可以给身体同样的bg颜色,并为内容背景设置一种新的颜色。啊,我明白你的意思了,我想。。。让我试一试,请继续关注。是的,成功,谢谢。不知道为什么我没想到。。。你能不能给身体与页脚相同的背景色?不,因为它是页脚上方的大部分身体颜色。然后我会遇到类似的问题。。。BF颜色填满了整个浏览器窗口,我的内容只有900-1000像素宽,大约。如果你有
FooFoo
,你可以给身体同样的bg颜色,并为内容背景设置一种新的颜色。啊,我明白你的意思了,我想。。。让我试一试,请继续关注。是的,成功,谢谢。不知道为什么我没想到。。。哈