Friday, 15 August 2014

html - My body background color disappears when scrolling -



html - My body background color disappears when scrolling -

i hope can help. i've set body height property 100% fine when content on screen @ 1 time. when need scroll (when minimizing window) body color disappears, leaving color set html background. know solution?

html { background-color: #07ade0; } body { background-color: #7968ae; width: 900px; margin-left: auto; margin-right: auto; font: 20px verdana, "sans serif", tahoma; }

if body set height: 100%, 100% of window, not ideal since background on longer pages cutting off, mentioned. take off height property , should set.

you can set height: 100% on both html, body , create container within body. move html styles body, , body styles new container.

this preferred, since not considered best practice set pixel width on body element.

html

<body> <div id="container">your well-endowed content goes here.</div> </body>

css

html, body { height: 100%; } body { background: #07ade0; } #container { background: #7968ae; width: 900px; margin-left: auto; margin-right: auto; font: 20px verdana, "sans serif", tahoma; overflow: hidden; }

see demo.

html css vertical-scrolling document-body

No comments:

Post a Comment