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??
3 Réponses
+ 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.
+ 1
<div style="width:70px;">
<div style="width:50%"></div>
/*width will be 35px*/
</div>
0
The value is base on the percentage of the element you assign it to or pick.