【发布时间】:2015-03-12 15:01:49
【问题描述】:
我想在 Drupal responsive 主题的 CSS style sheet 中以相对单位 (em) 设置字体大小。
我知道,最好使用相对字体大小单位:在我的情况下,它相对于body font-size (13px):但我不确定,这个值是否必须保留在 px 绝对单位中?如果我以相对单位 (em) 指定 body font-size,那么
我不能为所有其他元素使用em相对单位,因为设置相对于相对单位的单位没有意义。在这个特定的样式表中指定字体大小的正确方法是什么?
CSS(与问题相关的部分)如下所示:
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;
}
...
body {
font-family: 'Open Sans', sans-serif;
line-height: 160%;
color: #666;
font-size:13px;
background: #fff;
}
....
h1, h2, h3, h4, h5, h6 {
font-weight: bold;
margin-bottom:6px;
color: #555;
}
h1 { font-size:18px; }
h2 { font-size:16px; }
h3 { font-size:14px; }
h4 { font-size:13px; }
h5 { font-size:13px; }
h6 { font-size:13px; }
p { margin-bottom:18px;
color: #666;
}
...
#forum .name a{
font-size: 16px;
}
....
【问题讨论】:
-
您正在询问修改特定样式表,但问题不包括它。问题描述的重要部分只能通过外部链接获得的问题不适合 SO。此外,是的问题是什么?要求“正确的方式”是非常模糊的(并且是以意见为导向的)。并且将单位设置为相对于相对单位很有意义,因此关键假设是错误的。
-
我想以 em 为单位设置字体大小。所以我应该以像素为单位保留正文字体大小,并为所有其他元素设置 em 中的字体值。如果我也在 em 中设置 body font-size,这可能不会给我任何优势。如何将像素单位转换为 em,同时保留纵横比/比例?
标签: html css fonts responsive-design