CSS percentage widths and heights and resolution problems

雨燕双飞 提交于 2019-12-02 11:56:23

For Responsive Webdesign you really should be leveraging media queries

Personally I prefer pixels because they give me more control, and I can reliably know the exact dimensions of each element. With media queries you can also set new styles based on the screen resolution.

Percentages give you a nice responsive feel, but can be much more difficult to ensure you're layout is not junked by each level of resolution.

Both approaches are "reliable". However, if you are looking for auto-resizing, percentages is the way to go. If you do not want the elements to resize based on the size of the window, pixels would a better solution.

Percentage always applies to a percentage of the parent element, while pixels are always fixed. Percentages are more accessible especially on smaller monitors however you will run into problems with things line breaking at the wrong times and the like. For example, if you have a 50px image and 100px wide line of text, and you want the items on the same line, specify a 150px width, because if you specify a percent, they may appear right on your monitor but not others.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!