开发者

Giving width/height in pixels/percentage of HTML content

开发者 https://www.devze.com 2023-01-30 00:55 出处:网络
What is the 开发者_StackOverflow中文版exact difference between giving width/height of html contents in

What is the 开发者_StackOverflow中文版exact difference between giving width/height of html contents in pixels/percentage?

Are both of them same?

Are they play any role in browser compatibility ?

if different then which one is best?


in pixel: fixed size

in percentage : fluid to its parent element

I've never found different appearance between browsers related to this thing.

Which is the best, depends on your need.. whether you want to make it fixed size or fluid.


The difference comes in IE, and when using zoom feature.

hit ctrl + '+' key or ctrl + '-' and you will see everything expanding, if everything is in pixel, then it will create empty space and your elements wont expand, while if they are in percentage, they will expand.

Also, if any of the div/container has height/width set in absolute values {pixels} then all their child elements automatically becomes fixed.

The difference is same as using em instead of px for fonts.


They are different. If you use pixels then, its an absolute measurement and will be rendered irrespective of the browser's window size. And percentage is a relative measurement which will be rendered with respect to the browser's window size. If you want to show some element to always appear in a fixed size, then use pixels, else use percentage.

0

精彩评论

暂无评论...
验证码 换一张
取 消