How to remove margin space around body or clear default css styles

后端 未结 7 1426
夕颜
夕颜 2020-11-22 06:09

I am admittedly a beginner, but I also did a fair amount of searching before posting this. There seems to be extra space around my div element. I also would like to point ou

7条回答
  •  灰色年华
    2020-11-22 06:22

    body has default margins: http://www.w3.org/TR/CSS2/sample.html

    body { margin:0; } /* Remove body margins */
    

    Or you could use this useful Global reset

    * { margin:0; padding:0; box-sizing:border-box; }
    

    If you want something less * global than:

    html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, hgroup, menu, nav, section, time, mark, audio, video {
        margin: 0;
        padding: 0;
        border: 0;
        outline: 0;
        font-size: 100%;
        vertical-align: baseline;
        background: transparent;
    }
    

    some other CSS Reset:

    http://yui.yahooapis.com/3.5.0/build/cssreset/cssreset-min.css
    http://meyerweb.com/eric/tools/css/reset/
    https://github.com/necolas/normalize.css/
    http://html5doctor.com/html-5-reset-stylesheet/

提交回复
热议问题