我应该使用em还是px? [英] Should I use em or px?

查看:136
本文介绍了我应该使用em还是px?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始一个新的网络项目,我想知道是否使用em或px的布局和字体大小。

I'm starting off a new web project and I'm wondering whether to use em or px for the layout and font sizes.

尽管事实上大多数浏览器现在都支持文本和图像缩放,无论字体是以px还是em定义的,但是使用em的社区支持仍然很强大。

Despite the fact that most browsers now support text and image zooming regardless of whether fonts are defined in px or em, the community support for using em is still strong.

但是有两个问题,我看到使用em。

But there are 2 problems I see with using em.

首先是大型和宽屏显示器的问题 - 通常这会导致文本在屏幕上移动英里和英里,这在阅读页面时很难阅读。

First is the problem with large and wide monitors - often this results in text running miles and miles across the screen, which is very difficult to read as you read down the page.

其次,如果您的网站需要集成Flash组件怎么办?如果你想让Flash组件恰好放在em中定义的div(例如网站的主容器)里面,你会怎么做呢,因为Flash组件是用px测量的?

Secondly, what if your site needed to integrate a Flash component? If you want the Flash component to fit exactly inside a div (e.g the main container of the site) that is defined in em, how would you go about it since Flash components are measured in px?

有没有令人信服的理由使用EM over PX,真的吗?

Is there a compelling reason to use EM over PX, really?

推荐答案


首先是大型和
宽屏显示器的问题 - 通常这导致
文本运行英里和英里跨
屏幕,这是非常困难的
读取您读取

First is the problem with large and wide monitors - often this results in text running miles and miles across the screen, which is very difficult to read as you read down the page.

使用 em px ,您仍然可以为布局定义 width (或 max-width )。 / p>

Using em or px, you can still define a width (or max-width) to your layout.


其次,如果您的网站需要
集成Flash组件怎么办?如果你
想要Flash组件将
恰好放在一个div中(例如网站的主要
容器),它在em中定义为
,你会如何做呢?
Flash组件以px测量?

Secondly, what if your site needed to integrate a Flash component? If you want the Flash component to fit exactly inside a div (e.g the main container of the site) that is defined in em, how would you go about it since Flash components are measured in px?

完全符合要求,您仍然可以使用100%

To fit exactly, you can still use 100% width, or maybe I did not understand your point.

理论上,使用 em 而不是 px 将允许您的布局容易根据用户偏好大小。

In theory, using em instead of px will allow your layout to be easily sizable based on user preferences.

但今天,现代浏览器可以调整 px 布局以及 em 布局的大小,与几年前相同。

But today, modern browsers can resize px layouts as well as em layouts so it might not be as relevant as it was some years ago.

这篇关于我应该使用em还是px?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆