+ 6
Is pixel the same thing as %
html
13 odpowiedzi
+ 7
An object styled using px is fixed according to the size of pixels on a device. An object styled using % is relative to its container/max dimensions, and will adjust to fit different containers.
An object of height 50px is just what it is.
An object of height 50% would span half its container.
+ 5
Nope they are different
+ 4
thanks
+ 4
I assume you know that our screens are made of pixels. Assume you have a screen of length 1000 pixel. Now an element with 50% length would cover half the screen and an element with 50 px length will cover only 1/20th (5%) of the screen.
+ 4
No...pixels are defined according to resolution of the device but % is used relative to the block you are storing the object
+ 3
no, % means percentage of maximum width
lets make an example
<div style="width:100px;">
<div style="width:50%;">
</div>
</div>
the first div will be 100 pixels in width
the second one will be 50 pixels, because:
>the maximum width in % is inherited and is 100 pixels
>we took 50% of the maximum width, so it will be 50 pixels
+ 3
no bro.pixel is different and % is different.in pixels we can give how much pixels we divide in display.EG:height=50px.in this the display will divided into two part one part will divided into 50 pixels.and another part will divided into remaining pixels.for % EG:height=50%.in this the program will first convert % into pixels.then it will divide the display.in this the display will divided into half screen .because 50% means half.so it will divide into half screen one side and another half into another side
+ 3
Pixels are an absolute length. 1 pixel is equal to 1/96 of an inch . Percentages are relative to another value. 1% is 1/100 of another length.
Pixels is a fixed value. For example, the header on this site is fixed to 980px.
Percentage, well, it is a part of a parent measure where the browser is the outermost parent.
Pixel value is fixed however percent value may varry according to your screen resolutions.
+ 3
nope.. pixel is the fix thing it can be vary with screen size bt % very with screen size if width is set to 50% then in desktop of 1024px its with 512px and in mobile of 320px resolution gets 160px
+ 2
Pixels (px) :
Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.
Percent (%) :
The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.
+ 2
thanks
+ 1
yes my friend they are same. it's up to you what do you choose b/w px and %
- 2
yes no problem