CSS 中使用百分比和像素哪个更好?
我不是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用这种方法不会有任何问题,百分比和像素都可以根据您的需要正常工作。如果您需要一个流动的站点,那么百分比可能是您的最佳选择。 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
我想你应该看看这个:
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.
要根据分辨率或浏览器窗口的大小调整网站的大小,百分比将是您的最佳选择。您可能遇到的唯一问题是,如果分辨率非常低或浏览器窗口尺寸很小,则难以阅读内容,在这种情况下,内容可能会混乱并难以阅读。使用百分比而不是像素将使站点变得流动,并将根据窗口的分辨率和比例进行调整。
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.