0

When assigning the width and height of elements, it says we can use pixels or percentages. What is it a percentage "of"?

Meaning, if I assign the width of an element to be 100% (like in the example), what value is the percentage based on? Is it a set value no matter where you're writing it or what surrounds it, or is it determined by other parts of the specific coded "entity" it's written into??

17th Apr 2016, 4:44 PM
Sondra R. Coffin
Sondra R. Coffin - avatar
3 Antworten
+ 2
I think it is the perc of the parent element. Since this is just written in the body it applies to the entire screen. If you had an element in the body with a width of 50 px and another element inside it with a width of 50% its size would be 25 px.
25th Apr 2016, 10:53 PM
Toni
Toni - avatar
+ 1
<div style="width:70px;"> <div style="width:50%"></div> /*width will be 35px*/ </div>
27th Jun 2016, 9:33 PM
Matheus Prado
Matheus Prado - avatar
0
The value is base on the percentage of the element you assign it to or pick.
21st Aug 2016, 10:57 PM
Krystal
Krystal - avatar