灵活布局使用ems或%作为字体大小单位通常的做法是使用正文字体大小为62.5%
但Firefox的默认字体是14px,这导致布局比具有16px默认字体大小的其他字体小
我们不能只将body字体大小修复为10px,以便相对大小适用于每个浏览器。
答案 0 :(得分:1)
另外,除了@Ray的回答..
对于像这样的浏览器不一致,请考虑使用重置样式表。
我在这里粘贴代码是为了参考。
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
答案 1 :(得分:0)
你在这里说了很多正确的事情:
传统上,Ems和百分比一直是用于“可扩展”布局的单位。
CSS中的“级联”包括浏览器自己的样式表。因此,每当您省略某个元素的样式属性时,它会搜索级联,并从链接末尾的浏览器样式表中获取这些缺失的属性。
如果您希望页面文本的像素完美字体处理在浏览器中看起来相同,则需要自己定义字体大小。在px
元素上使用body
可以为您提供所需内容。我不知道为什么这仍然是个问题。曾经有一段时间,有些人会避免使用px
,但是现代浏览器可以很好地处理缩放,因为我怀疑它不是一个问题。