代码之家  ›  专栏  ›  技术社区  ›  user2252219

HTML背景色未更改

  •  0
  • user2252219  · 技术社区  · 12 年前

    我将html的背景设置为一种颜色,但它似乎不起作用。我已经包含了我的html和css来显示问题。

    html {height:100%; background-color:#e2e2e2;}
    

    http://jsbin.com/tixacemo/1/edit?html,css,output

    3 回复  |  直到 12 年前
        1
  •  2
  •   BMcNamara    12 年前

    去除

    CSS文档*/

    从CSS文件中。这将破坏对文件的分析。正确的注释以/*开头,以结尾*/

        2
  •  0
  •   MickyScion    12 年前

    在你的css头上这样放

    @charset "utf-8";
    
    
    html, body{
        height:100%; background-color:#e2e2e2;z-index:999;
    }
    

    删除 CSS Document */

        3
  •  0
  •   meeming    12 年前

    在进行样式设置之前,需要重置html元素:

    /*
    =RESET :Eric Meyer Reset Reloaded
    (http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/)
    ---------------------------------------- */
    html,body,div,span,applet,object,iframe,
    h1,h2,h3,h4,h5,h6,p,blockquote,pre,
    a,abbr,acronym,address,big,cite,code,
    del,dfn,em,font,img,ins,kbd,q,s,samp,
    small,strike,strong,sub,sup,tt,var,
    dl,dt,dd,ol,ul,li,
    fieldset,form,label,legend,
    table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
    :focus{outline:0;}
    body{line-height:1;color:black;background:white;}
    ol,ul{list-style:none;}
    table{border-collapse:separate;border-spacing:0;}
    caption,th,td{text-align:left;font-weight:normal;}
    blockquote:before,blockquote:after,
    q:before,q:after{content:"";}
    blockquote,q{quotes:"" "";}
    
    /* html 5 Specific */
    article,aside,canvas,details,div,figcaption,figure,
    footer,header,hgroup,menu,nav,section,summary,
    time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;}
    article,aside,canvas,details,figcaption,figure,
    footer,header,hgroup,menu,nav,section,summary,
    time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;}
    article,aside,canvas,details,figcaption,figure,
    footer,header,hgroup,menu,nav,section,summary{display:block;}
    
    
    /* www.aestheticallyloyal.com/public/optimize-legibility/ */
    body { text-rendering: optimizeLegibility; }
    /* maxvoltar.com/archive/-webkit-font-smoothing */
    html { -webkit-font-smoothing: antialiased; } 
    

    将上面的样式粘贴到样式表的顶部,或使用 <link href="reset.css" rel="stylesheet" type="text/css">
    然后你会看到背景颜色的变化。