我确实是一个初学者,但在发布之前我也做了大量的搜索.我的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 */
或者你可以使用这个有用的全局重置
如果你想要的东西少于*全局比:
- 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/…