\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Phil35} \pdfinfo{ /Title (flex-anti-seche-2018.pdf) /Creator (Cheatography) /Author (Phil35) /Subject (Flex Anti-sèche 2018 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{88499C} \definecolor{LightBackground}{HTML}{F7F3F8} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Flex Anti-sèche 2018 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Phil35} via \textcolor{DarkBackground}{\uline{cheatography.com/53795/cs/14489/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Phil35 \\ \uline{cheatography.com/phil35} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 1st February, 2018.\\ Updated 1st February, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Sources}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Cette anti-sèche reprend principalement le tutoriel \newline % Row Count 2 (+ 2) \{\{link="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"\}\}A Complete Guide to Flexbox (en)\{\{/link\}\} \newline % Row Count 5 (+ 3) et accessoirement le tutoriel : \newline % Row Count 6 (+ 1) \{\{link="https://www.alsacreations.com/tuto/lire/1493-CSS3-Flexbox-Layout-module.html\#flexibilité"\}\}alsacreations : CSS3 Flexbox Layout module : flexibilité (fr)\{\{/link\}\} \newline % Row Count 10 (+ 4) Notez le code couleurs : \newline % Row Count 11 (+ 1) Violet : pour les attributs du container parent (considérer comme synonimes parent et container ) \newline % Row Count 13 (+ 2) Orange : pour les atributs des articles enfants (considérer comme synonimes items, articles, enfants) \newline % Row Count 16 (+ 3) Lorsqu'un attribut peut prendre plusieurs valeurs, la valeur par défaut est indiquée en {\bf{{\emph{gras.}}}}% Row Count 19 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Propriétés du parent (couleur violet \#88499C )}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517400056_flex-container.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{display: flex; /{\emph{ or inline-flex }}/}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{.container \{ \newline display: flex; /* or inline-flex */ \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{déclaration obligatoire qui crée le parent flexbox} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{direction principale}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517404431_flex-direction2.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.container \{` \newline ` flex-direction: {\bf{{\emph{row}}}} | row-reverse | column | column-reverse;` \newline `\} `} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{flex-wrap}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517404585_flex-wrap.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.container\{` \newline ` flex-wrap: {\bf{{\emph{nowrap}}}} | wrap | wrap-reverse;` \newline `\}` \newline wrap ou wrap-reverse va définir le sens de l'{\bf{axe secondaire}} (cross axes)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{flex-flow = flex-direction + flex-wrap}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{.container\{ \newline flex-flow: \textless{}'flex-direction'\textgreater{} || \textless{}'flex-wrap'\textgreater{}` \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{justify-content (axe principal)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517405143_justify-content-2.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.container \{` \newline ` justify-content: {\bf{{\emph{flex-start}}}} | flex-end | center | space-between | space-around | space-evenly;` \newline '\}` \newline choisir une possibilité parmi les six...} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{align-items : alignement relatif à une ligne}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517405316_align-items.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.container \{` \newline ` align-items: flex-start | flex-end | center | baseline | {\bf{{\emph{stretch}}}};` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{align-content: alignement entre plusieurs lignes}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517405520_align-content.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.container \{` \newline ` align-content: flex-start | flex-end | center | space-between | space-around | {\bf{{\emph{stretch}}}} ;` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Propriétés des enfants (couleur orange \#E77F24 )}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517400165_flex-items.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{item : align-self ( individuels / items)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517406158_align-self.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.item \{` \newline ` align-self: auto | flex-start | flex-end | center | baseline | stretch; ` \newline `\}` \newline Permet de surcharger pour des articles les règles générales définies au niveau container-parent.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{order: modifier l'ordre.}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517406367_order-2.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`.item \{` \newline ` order: \textless{}integer\textgreater{}; /{\emph{ default is 0 }}/` \newline `\}` \newline Tous les items ayant le même niveau order sont affichés dans l'ordre d'aparition.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{flex: raccourci grow + shrink + basis}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{La propriété flex est un raccourci de trois propriétés, qui s'appliquent aux "flex-items" et dont les fonctionnalités sont: \newline % Row Count 3 (+ 3) {\bf{flex-grow}} : capacité pour un élément à s'étirer dans l'espace restant (0 ou n) \newline % Row Count 5 (+ 2) {\bf{flex-shrink}} : capacité pour un élément à se contracter si nécessaire (0 ou 1) \newline % Row Count 7 (+ 2) {\bf{flex-basis}} : taille initiale de l'élément avant que l'espace restant ne soit distribué ( \textless{}length\textgreater{} ou "auto" ) \newline % Row Count 10 (+ 3) `.item \{` \newline % Row Count 11 (+ 1) ` flex: none` \newline % Row Count 12 (+ 1) ` flex:\textless{}'flex-grow'\textgreater{} \textless{}'flex-shrink'\textgreater{} \textless{}'flex-basis'\textgreater{} ` \newline % Row Count 14 (+ 2) ` flex:\textless{}'flex-grow'\textgreater{}` \newline % Row Count 15 (+ 1) `\}` \newline % Row Count 16 (+ 1) Par défaut, les valeurs de ces propriétés sont : \newline % Row Count 18 (+ 2) {\bf{flex-grow: 0, flex-shrink: 1 et flex-basis: auto}} \newline % Row Count 20 (+ 2) En clair, les flex-items n'occupent initialement que la taille minimale de leur contenu. \newline % Row Count 22 (+ 2) Pour rendre {\bf{un}} élément flexible, il suffit de lui attribuer une valeur de flex-grow (ou flex en raccourci) supérieure à zéro. \newline % Row Count 25 (+ 3) Cet élément absorbera alors l'espace restant au sein de son conteneur. \newline % Row Count 27 (+ 2) {\bf{Plusieurs éléments}} peuvent être rendus flexibles et se répartir l'espace restant. L'espace disponible est alors tout simplement distribué entre les éléments flexibles (proportionnellement à leur coefficient flex-grow ) \newline % Row Count 32 (+ 5) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{flex: raccourci grow + shrink + basis (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{link="https://www.alsacreations.com/tuto/lire/1493-CSS3-Flexbox-Layout-module.html\#flexibilité"\}\}www.alsacreations.com/tuto/lire/1493-CSS3-Flexbox-Layout-module.html\{\{/link\}\}% Row Count 4 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{il est recommandé d'utiliser ce raccourci plutôt que les valeurs séparément.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{flex-grow: répartition de l'espace}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517406672_flex-grow.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`item \{` \newline ` flex-grow: \textless{}number\textgreater{}; /{\emph{ default 0 }}/` \newline `\}` \newline La place est répartie proportionnellement aux coefficients attribués. \newline Pour un effet parfait, il faut avoir assez de place vide avant redistribution.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Utiliser la propriété margin:auto pour centrer}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/phil35_1517478903_center.hd720.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Il est possible de positionner un élément en bas de son conteneur à l'aide d'un : \newline {\bf{margin-top: auto}}, \newline ou mieux : centrer à la fois horizontalement et verticalement via un simple : \newline {\bf{margin: auto}}. \newline \newline ` /* paragraphe centré horizontalement et verticalement */` \newline `.container \{` \newline ` display: flex;` \newline `\}` \newline `.container \textgreater{} p \{` \newline ` margin: auto;` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}