html - 不同标题显示相同的字体大小

标签 html css

HTML:

<h1>The Repository For Your Photos.</h1>
<h2>The Repository For Your Photos.</h2>
<h3>The Repository For Your Photos.</h3>
<h4>The Repository For Your Photos.</h4>

CSS 重置:

html, body, div, span, 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%;
    vertical-align: baseline;
    font-family: "Myriad Set Pro", "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
}

结果:https://jsfiddle.net/h8wcL2cr/2/

为什么它们都一样?

最佳答案

因为您使用的是 CSS Reset 样式表,并且您将 font-size:100% 应用于从 h1h6 的所有标题> 这会将 font-size 重置为浏览器默认值

因此,您必须重新设置标题的样式

html, body, div, span, 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%;
    vertical-align: baseline;
    font-family: "Myriad Set Pro", "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
}  
h1 {font-size:150%}
h2 {font-size:80%}
h3 {font-size:65%}
h4 {font-size:45%}
<h1>The Repository For Your Photos.</h1>
<h2>The Repository For Your Photos.</h2>
<h3>The Repository For Your Photos.</h3>
<h4>The Repository For Your Photos.</h4>

关于html - 不同标题显示相同的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36023793/

相关文章:

javascript - 从 html 和 javascript 中的下拉选择中调用函数

javascript - 忽略 querySelectorAll 中的区分大小写

javascript - 如何使用 jquery 从左到右或从右到左为 2 个 css 布局设置动画?

JavaScript localStorage - 来自多个用户卡的文本输入

html - Angular HTML 标记 - 表格导致错误

jquery - 如何根据浏览器/导航器应用不同的 iframe 标签

javascript - html/php表单计算简单公式的显示结果

css - 如何在 IE 7 中使用 HTML5?

javascript - iOS 8 移除了 "minimal-ui"视口(viewport)属性,还有其他 "soft fullscreen"的解决方案吗?

html - Bootstrap 4 中右侧 float 的样式不起作用