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

前端之家收集整理的这篇文章主要介绍了html – 如何清除身体周围的边缘空间或清除默认的CSS样式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我确实是一个初学者,但在发布之前我也做了大量的搜索.我的div元素周围似乎有更多的空间.我还想指出,我尝试了许多边框组合:0,padding:0等,没有什么似乎摆脱了空白.

这是代码

  1. <html>
  2. <head>
  3. <style type="text/css">
  4. #header_div {
  5. background: #0A62AA;
  6. height: 64px;
  7. min-width: 500px;
  8. }
  9. #vipcentral_logo { float:left; margin: 0 0 0 0; }
  10. #intel_logo { float:right; margin: 0 0 0 0; }
  11. </style>
  12. </head>
  13. <body>
  14. <div id="header_div">
  15. <img src="header_logo.png" id="vipcentral_logo">
  16. <img src="intel_logo.png" id="intel_logo"/>
  17. </div>
  18. </body>

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

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

解决方法

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

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

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

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

  1. 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 {
  2. margin: 0;
  3. padding: 0;
  4. border: 0;
  5. outline: 0;
  6. font-size: 100%;
  7. vertical-align: baseline;
  8. background: transparent;
  9. }

一些其他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/

猜你在找的HTML相关文章