Skip to content
Basarat Ali Syed edited this page Nov 24, 2015 · 7 revisions

Never use % in a flex box

You will get a random jank in the layout if you do so.

  • If you want a child to be 100% in a single direction, just have the parent layout in the cross dimension (e.g. a vertical layout will automatically have its children 100% width).

  • If you want a child to be 100% in both dimensions, then use vertical on parent and flex on the child to have it take up all available parent space.

padding not margin

Margins collapse, padding doesn't. If you want a maintainable layout don't be lazy and use margin, instead just wrap in a div

<div> <!-- use padding on this div -->
    <!-- the content you want margined -->
</div>

inline-block not inline

If you are curious here is a visual difference. Don't have something that completely ignores its height property. Also, inline doesn't work with CSS transforms.

Center text in a div

You can use the styles csx.flexRoot + csx.center however it will eat up empty spans so you should combine with whiteSpace:'pre'.