简体   繁体   中英

Why does my background-color not fill all of my page?

I have the following HTML:

<!doctype html>
<html lang="en" class="light">
<head>
.....
</head>
<body>
...
...
...

And my CSS looks like this:

html.light body
{ background-color:#15293E ; }

I have text on my page that is long enought that a scroll bar appears. However when I scroll to the bottom I notice the background color does not go all the way to the bottom of the page.

Is there something wrong with what I am doing. It's seems like simple HTML but I cannot get the background color to fill the page.

Option 1 :

  • You have a fixed height like height:100% or max-height in your body/html styles

Option 2 :

  • Your content is floating or with position:absolute and thus the body is not extending as far as the content seems to extend.

尝试为根指定百分之百的高度:

html, body { height:100%; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM