开发者

html element background color not showing in IE 8

开发者 https://www.devze.com 2023-02-18 16:18 出处:网络
I\'m using the <body> t开发者_JAVA百科ag as a wrapper for three divs on a site where every single background color is white.

I'm using the <body> t开发者_JAVA百科ag as a wrapper for three divs on a site where every single background color is white.

I've set the background color to #fff for the html and body in the css, and the site is rendering correctly in every browser (including IE 6 and 7) except IE8:

html element background color not showing in IE 8

I've even tried setting the style for html directly inline like so: <html style="background-color: #fff"> but that doesn't seem to change anything.

Not even sure what might be causing the bug.


The problem is the following property in your CSS:

:focus{
  outline:0;
  background-color:#f2f3f6;
  border-color:#996
}

Apparently, on loading IE8 decides that the html element has focus, whereas other browsers don't do this. Remove the background-color property here and it'll all stay white.


What happens when you insert this code into your HTML?

body div
{
  background-color: white !important;
}

Normally, browsers interpret and apply the last line of CSS that they read to an element, so background-color: red; background-color: blue; would result in a blue background color.

!important tell the browser to ignore all other property re-decelerations, so background-color: red !important; background-color: blue; would make the background color red, even though you told it to be blue.


I think background:#FFFFFF; will fix it. It worked for me.


internet explorer support 6digit color code i.e. instead of #fff .. use #ffffff I hope you may understand this

0

精彩评论

暂无评论...
验证码 换一张
取 消