I have a designed a website.I am new to css, html, php so in css I have used all sizes in px. But when I change the screen resolution, webpage content is not proper, meaning its like:
When I zoom out this is the result how to handle this in css?? When I googled about same I found that instead of using px I should use em / %.
What is to be used?
for widths and heights.
Edit1
after zoom out
Websites having a percent (%) width for the main content area is not adviced because of the inconsistency. It's best to use a pixel width of about 960 pixels, maybe a bit less, for the whole website, so that it will work for all resolutions.
As for elements inside the main content area, it is better to use percent widths because it doesn't make sense to both with calculating the exact pixel values. The result is set fixed, because the thing that it's a percentage of parent's fixed width, as opposed to the monitor's resolution, which varies between users.
It is better to use a fixed width parent with a wrap
of 960px
and use fluid (%
) element widths inside the wrap
.
To get started, you can use this sample code:
<div class="wrap">
<!-- Other Elements -->
</div>
.wrap {margin: 0px auto; width: 960px;}
For more information, do check out this question on Programmers: https://softwareengineering.stackexchange.com/questions/135506/percent-or-pixels-html-css