css - Understanding the flexible padding -
page
Ethan Marcote in responsive web design under regular box model. 35, wrote: When setting flexible padding on an element, your reference is the width of the element . Please take a look at the following example: My question is this: What is written about that book, the padding setting: Shoddan 'is not correct (but this is!). What am I not getting here? I have not read the book you mentioned and it is difficult to guess what it says because I have no reference around the sentence of quote. It said, if you reproduce the percent padding calculation again: percent calculate percent of the generated generator box In relation to the width of the block's, [...] then the percentage is calculated according to parent's width and therefore < Code> 2.083333333333% the value is correct.
.main-wrapper {width: 98%; / * 960px - to give some space on viewport * / .box-one. Box-two {width: 44.7 966666667%; / * 430/960 * / float: left; Margin: 30px 0 20px 0; Padding: 2.083333333333%; / * Padding 20px * / text-alignment: center; }. Box-A {margin-right: 2.083333333333%; / * Margin is relative to the container (960px here), therefore: 20/960 * / background color: red; }. Box-two {background-color: blue; }
& lt; Div class = "main-wrapper" & gt; & Lt; Div class = "box-one" & gt; & Lt; P & gt; One box here & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "box-two" & gt; & Lt; P & gt; Two box here & lt; / P & gt; & Lt; / Div & gt;
Padding: 2.083333333333%; Instead, we should keep in mind element width and it is
430px . But if we use that value as a reference, then we get 4.x%.
Comments
Post a Comment