CSS 中使用百分比和像素哪个更好?

发布于 2024-12-13 02:46:58 字数 174 浏览 2 评论 0原文

我不是 CSS 专家,但我想要制作一个在所有浏览器和分辨率下都看起来不错的设计。我注意到有些网站使用百分比而不是像素进行设计(宽度高度边距填充) ,我也用百分比进行所有设计。这种做法有什么问题吗?

请告诉我。

I am not a CSS expert and I want to make a design that will look good in all browsers and resolutions. I noticed that some websites make their design (width, height, margin, padding) with percentage, not pixels, and I am doing all my design with percentage too. Does this approach have any problems?

Please advise me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

め可乐爱微笑 2024-12-20 02:46:58

使用这种方法不会有任何问题,百分比和像素都可以根据您的需要正常工作。如果您需要一个流动的站点,那么百分比可能是您的最佳选择。 ems 表示字体,因此用户可以根据需要修改其显示。

一些专家对此的看法:

https:/ /kyleschaeffer.com/css-font-size-em-vs-px-vs-pt-vs-percent

http://webdesign.about.com/cs/typemeasurements/a/aa042803a.htm< /a>

这是一个有趣的变化:百分比+像素:

http://www.cssplay.co.uk/boxes/outside.html

You won't have any problems using this approach, both percentage and pixels work fine depending on your needs. If you need a fluid site, then percentage might be your best option. And ems for the fonts, so the user can modify its display if necessary.

Couple of expert's opinions on this:

https://kyleschaeffer.com/css-font-size-em-vs-px-vs-pt-vs-percent

http://webdesign.about.com/cs/typemeasurements/a/aa042803a.htm

And here's an interesting twist: Percentage + pixels:

http://www.cssplay.co.uk/boxes/outside.html

我们的影子 2024-12-20 02:46:58

我想你应该看看这个:

http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/

这取决于你的需求,我倾向于使用 em 而不是像素或者百分比。我还注意到 IE 并不能很好地“吃”百分比,但 ems 工作得很好。

I guess you should have a look at this:

http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/

It depends on your needs, I tend to use em instead of pixels or percentages. Also I've noticed that IE does not "eat" percentages too well but ems are working great.

情感失落者 2024-12-20 02:46:58

要根据分辨率或浏览器窗口的大小调整网站的大小,百分比将是您的最佳选择。您可能遇到的唯一问题是,如果分辨率非常低或浏览器窗口尺寸很小,则难以阅读内容,在这种情况下,内容可能会混乱并难以阅读。使用百分比而不是像素将使站点变得流动,并将根据窗口的分辨率和比例进行调整。

To have the site scale depending on the resolution or the size of the browser window, percents will be your best bet. The only problem you may run into is difficulty reading content if the resolution is very low or the size browser window is small, in which case the content may jumble up and make it difficult to read. using percentages rather than pixels will make the site liquid and will adjust according to resolution and scale of the window.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文