HTML 应该使用什么单位?
我喜欢使用 em,并且倾向于远离 %,因为它很容易搞砸设计,而 pt、px、cm...因为它们对所有设备都不太友好。我这样做对吗?
I like to use em, and tend to stay away from % because it tends to screw up the design easily, and pt, px, cm... Because they aren't that friendly to all devices. Am I right in doing so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CSS 为您提供选择是有原因的。所以这其实并不是一个对错的问题。但是,如果您正在寻找一种通过使字体和元素缩放更容易来使您的网站更易于访问的方法,那么您就走在正确的道路上。和他们一起去吧。
There are reasons why css offers you a choice. So it isn't really a question of right or wrong. But if you are looking for a way to make your site more accessible by making fonts and elements scale easier, then you are on the right path. Go with em.
这取决于。使用 em 将尺寸链接到字体大小,使用 % 链接到容器(最终是屏幕)的大小。在某些地方,一个人会比另一个人更好地达到一致的效果。我同意避免绝对单位通常是好的,但 px 对于小尺寸(例如边框宽度、垫片)很有用。
It depends. Using em links dimensions to the font size and using % links to the size of the container (and ultimately the screen). In some places one will be better than the other for achieving a consistent effect. I agree it is generally good to avoid absolute units, but px is useful for small dimensions (e.g. border widths, shims).
是的。它具有可扩展性,易于记忆,甚至易于转换为其他测量值进行比较:)
Yes. It scales, its easy to remember, and even easy to convert into other measurements for comparison :)