div元素中的额外空间的解 [英] solution for extra space in div element

查看:85
本文介绍了div元素中的额外空间的解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用一个 div 元素。



如何清除?



谢谢

解决方案

每个浏览器都有自己的默认值,用于各种元素的边距和填充。除非你明确设置例如

  div {
margin:0;
padding:0;
}

在你的CSS样式表中,



更令人烦恼的是,每个不同的浏览器将有不同的默认值填充和边界div。 Firefox可能有10px的边距,IE可能有8px的边距。



我发现最好是在样式表的顶部将所有这些默认值重置为零。例如

  html,body,div,span,object,iframe,
h1,h2,h3,h4, h5,h6,p,blockquote,pre,
table,caption,tbody,tfoot,thead,tr,th,td {
margin:0;
padding:0;
border:0;事实上,对于这个我使用辉煌的

$ < /blueprintcss.org/rel =nofollow> Blueprint CSS
,因为它包含一个reset.css文件,它包含了这个秘诀!


In my application I am using a div element. There is some extra space found below and above the div element.

How can I remove that?

Thanks

解决方案

Each browser has it's own default values for margin and padding on various elements. So unless you explicitly set eg.

div {
margin:0;
padding:0;
}

in your CSS stylesheet, there will be some spacing below and above your div.

What's more annoying is that each different browser will have different default values for padding and margin on divs eg. Firefox might have 10px margin and IE may have 8px margin.

I find it is best to initially reset all these defaults to zero at the top of my stylesheets. eg.

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
table, caption, tbody, tfoot, thead, tr, th, td {
  margin: 0;
  padding: 0;
  border: 0;
}

In fact for this I use the brilliant Blueprint CSS as it has a reset.css file included which does the trick!

这篇关于div元素中的额外空间的解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆