OS特定的样式表属性是什么?

时间:2014-03-08 10:19:20

标签: html css

在我们的网站上,我们使用了一些自定义字体,我注意到按钮,输入元素等方面的差异是否与文本垂直对齐。填充和其他属性对Linux / MAC和PC有不同的影响。

你能告诉我什么CSS属性可能导致每个操作系统不同的结果? 使用em / rem或px是否更好,或者在这种情况下无关紧要?

例如,以下规则将在Windows上的Chrome中垂直对齐文本,但在Ubuntu上不在Chrome中。

.btn {
  font-size: 1.5rem;
  line-height: 2.2rem;
  vertical-align: middle;
}

1 个答案:

答案 0 :(得分:1)

操作系统与HTML和CSS渲染无关。它是负责财产差异的浏览器。每个浏览器都有自己的实现方式,因此它的浏览器社区在浏览器的不同平台上创造了差异。要使所有浏览器中的所有内容都相同,建议在顶部包含reset.css

Reset.css

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

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;
}