简体   繁体   English

Em字体大小是在我的h1顶部添加边距?

[英]Em font size is adding margin to the top of my h1?

I started using a CSS reset (YUI) for the first time with my personal site at http://www.tommaxwell.me , and it has helped a lot with cross-browser compatibility. 我第一次使用我的个人网站http://www.tommaxwell.me开始使用CSS重置(YUI),并且它在跨浏览器兼容性方面提供了很多帮助。 However, in webkit browsers (Chrome, Safari), the ems font size seems to be adding margin to the top of the h1. 但是,在webkit浏览器(Chrome,Safari)中,ems字体大小似乎是在h1的顶部添加了边距。 When I remove the em, it falls back the default size and doesn't have the margin on the top. 当我删除它时,它会回退到默认大小,并且顶部没有边距。 In Opera and Firefox that margin isn't there. 在Opera和Firefox中,保证金不存在。 What should I do? 我该怎么办?

kindly try to use px instead or try this 请尝试使用px或试试这个

.webkit h1{margin:0px}

thanks hope it would help .. 谢谢希望它会有所帮助..

If you Inspect h1 Element then you will see that all margins are 0 for h1 tag. 如果您检查h1元素,那么您将看到h1标记的所有边距都为0。

But height varies for h1 tag in all browsers and this is due to their rendering engine. 但是所有浏览器中h1标签的高度都不同,这是由于它们的渲染引擎。 And that variation maybe creating illusion for you about margin 而这种变化可能会为你创造关于保证金的错觉

I'm not sure what you mean as they look same to me across most browsers, but I can't see you setting a line-height anywhere, as a suggestion it may be worth fiddling with the line-height to see if the space is coming from there? 我不确定你的意思是什么,因为它们在大多数浏览器中看起来都一样,但我看不到你在任何地方设置行高,作为一个建议,可能值得摆弄行高,看看是否有空间来自那里?

h1 {
    line-height: 1.0em;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM