+ 1
what is the difference between px and % ?
4 Antworten
+ 2
"px" is relative to the number of pixels of the screen.
"%" is relative to a certain dimension of the containing block (the tag). E.g.:
#box1 {
width: 50%;
height: 50%;
}
#box2 {
width: 50%;
height: 50%;
}
<body>
<div id="box1">
<div id="box2"/>
</div>
</body>
box1 has half width and length of body and box2 has half width and length of box1.
+ 1
A percentage means that depending on the width of the window, the width will change. A pixel width means that no matter the window size, the width will always be the same.
One has application for fluid-layouts (%) and the other for fixed-width layouts (px)
+ 1
px is ervery time the same but the % is on every website different
0
Set body width to 80% and the other to 800 pixels. Resize your browser and see the difference.