How to get flexbox to enable padding in calculations?
In your code, adding is included in the calculations.
According to specification 1A + 1B = 2A
I do not believe that is right. Maybe a link to a link for an explanation.
flex-grow property
When you apply flex: 1 to an element, you use the flex transcript property to say the following:
flex-grow: 1flex-shrink: 1flex-basis: 0
flex-grow tells the flex item to use free space in the container.
Here is your code:
.Item { display: flex; flex: 1; flex-direction: column; padding: 0 10px 10px 0; }
The first line of padding-right: 10px applies to the three elements.
In the second line, padding-right: 10px is applied to two flexible elements.
Therefore, the first line of 10px has less free space for distribution. This disrupts the alignment of the grid.
To allocate space (for example, you want the element to occupy the remaining height or width of the container), use flex-grow .
To accurately determine the size of an element, use flex-basis , width or height .
Here is some more info:
- flex-grow does not match flex items as expected
- How does flex-grow work with flexbox?
Michael_B
source share