微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 如何清除身体周围的边缘空间或清除默认的CSS样式

我确实是一个初学者,但在发布之前我也做了大量的搜索.我的div元素周围似乎有更多的空间.我还想指出,我尝试了许多边框组合:0,padding:0等,没有什么似乎摆脱了空白.

这是代码

<html>
<head>
    <style type="text/css">
        #header_div  {
            background: #0A62AA;
            height: 64px;
            min-width: 500px;
        } 
        #vipcentral_logo { float:left;  margin: 0 0 0 0; }
        #intel_logo      { float:right; margin: 0 0 0 0; }
    </style>
</head>
<body>
    <div id="header_div">
        <img src="header_logo.png" id="vipcentral_logo">
        <img src="intel_logo.png" id="intel_logo"/>
    </div>
</body>

这是它的样子(我插入红色箭头显式调出额外的空间):

我期待蓝色直接与浏览器边缘和工具栏对齐.图像高达64像素高,并且具有与分配给#header_div的背景颜色相同的背景颜色.任何信息将不胜感激.

解决方法

身体具有认边距: http://www.w3.org/TR/CSS2/sample.html
body { margin:0; } /* Remove body margins */

或者你可以使用这个有用的全局重置

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

如果你想要的东西少于*全局比:

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;
}

一些其他CSS重置:

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/

原文地址:https://www.jb51.cc/html/230353.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐