html - 你为什么要 “NEVER use height in px on anything with text inside” ?

标签 html css

在演示中'Maintainable CSS' by Natalie Downe ,我看到一条建议说:

"be afraid of heights, vertigo is healthy on the web. NEVER use height in px on anything with text inside"

这是为什么?

最佳答案

我猜这是由于两个原因:

  1. Web 文档应该是流畅的。如果您的高度固定并且稍后需要添加或删除文本,会发生什么情况?
  2. 用户可以更改字体大小。关于演示者为何特别挑出像素:px 中的高度不随字体大小缩放,而至少 em 中的高度会缩放。

关于html - 你为什么要 “NEVER use height in px on anything with text inside” ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6277066/

相关文章:

html - 固定的 div 栏即使在 z-indexing 之后也不会出现在顶部

javascript - 按键或输入时如何防止ONBLUR事件?

javascript - 创建切换按钮以在 div 面板之间切换

html - 显示 HTML5 进度条的内部文本?未实现的技术原因?

php - 使用Jquery实现翻转效果

css - Zurb 基础 div 对齐问题

css - div 向两个方向倾斜

MS Edge 上的 CSS 边框问题

html - fieldset 中的 <pre> 不遵守 "overflow: auto"指令

html - MySQL - 从内容列内的 href 属性中存在的动态 url 中搜索并替换文本 (".html")