Issue with background color and Google Chrome

后端 未结 22 1107
一向
一向 2020-12-08 02:06

Sometimes I get a broken background in Chrome. I do not get this error with any other browser.

This is the simple CSS line responsible for the background color of b

22条回答
  •  北海茫月
    2020-12-08 02:57

    Ok guys, I found a solution, . It's not great but does the trick with no side effects.

    The HTML:

     
    

    (put this below the body tags)

    The CSS:

    #chromeFix { display: block; position: absolute; width: 1px; height: 100%; top: 0px; left: 0px; }
    

    What this does to solve the issue:

    It forces Chrome to think the page's content is 100% when it's not - this stops the body 'appearing' the size of the content and resolves the missing background bug. This is basically doing what height: 100% does when applied to the body or html but you don't get the side effect of having your backgrounds cut off when scrolling (past 100% page height) like you do with a 100% height on those elements.

    I can sleep now =]

提交回复
热议问题