Issue with background color and Google Chrome

后端 未结 22 1097
一向
一向 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:50

    I had the same thing in both Chrome and Safari aka Webkit browsers. I'm suspecting it's not a bug, but the incorrect use of css which 'breaks' the background.

    In the Question above, the body background property is set to:

    background: black;
    

    Which is fine, but not entirely correct. There's no image background, thus...

    background-color: black;
    
    0 讨论(0)
  • 2020-12-08 02:52

    I'm seen this problem with Chrome too, if I remember correctly if you minimize and then maximize your window it fixes it as well?

    Haven't really used Chrome too much since it was released but this is definitely something I blame on Google as the code I was checking it on was air tight.

    0 讨论(0)
  • 2020-12-08 02:52

    Everybody has said your code is fine, and you know it works on other browsers without problems. So it's time to drop the science and just try stuff :)

    Try putting the background color IN the body tag itself instead of/as-well-as in the CSS. Maybe insist again (redudantly) in Javascript. At some point, Chrome will have to place the background as you want it every time. Might be a timing-interpreting issue...

    [Should any of this work, of course, you can toggle it on the server-side so the funny code only shows up in Chrome. And in a few months, when Chrome has changed and the problem disappears... well, worry about that later.]

    0 讨论(0)
  • 2020-12-08 02:54

    Google Chrome and safari needs a tweak for body and background issues. We have use additional identifier as mentioned below.

    <style>
    body { background:#204960 url(../images/example.gif) repeat-x top; margin:0; padding:0; font-family:Tahoma; font-size:12px; }
    
    #body{ background:#204960 url(../images/example.gif) repeat-x top; margin:0; padding:0; font-family:Tahoma; font-size:12px;}
    </style>    
    <body id="body">
    

    Use both body and #body identifier and enter same styles in both. Make the body tag with id attribute of body.

    This works for me.

    0 讨论(0)
  • 2020-12-08 02:54

    Oddly enough it doesn't actually happen on every page and it doesn't seem to always work even when refreshed.

    My solutions was to add {height: 100%;} as well.

    0 讨论(0)
  • 2020-12-08 02:55

    HTML and body height 100% doesn't work in older IE versions.

    You have to move the backgroundproperties from the body element to the html element.
    That will fix it crossbrowser.

    0 讨论(0)
提交回复
热议问题