\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{Tse Han} \pdfinfo{ /Title (css-cheat-sheet.pdf) /Creator (Cheatography) /Author (Tse Han) /Subject (CSS 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}{0D5DA3} \definecolor{LightBackground}{HTML}{EFF4F9} \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{CSS Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Tse Han} via \textcolor{DarkBackground}{\uline{cheatography.com/210237/cs/45336/}}} \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}Tse Han \\ \uline{cheatography.com/tse-han} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 29th December, 2024.\\ 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{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Font Styles}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=30\}\}font-family & Use to declare multiple fonts, if first font doesn't exists other ones will be declared \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} font-size & Text size (e.g. 30px) \tn % Row Count 5 (+ 1) % Row 2 \SetRowColor{LightBackground} font-weight & Text thickness (bold, semibold) \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} font-style & Style of font (e.g. italic) \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} font-variant & Variation of font (e.g. small-caps) \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Colors}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=60\}\}Predefined Color Names & red, blue, green \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} RGB (Red, Green, Blue) & Red: rgb(255,0,0) \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} HEX (Hue, Saturated, Lightness) & Red: hsl(0, 100\%, 50\%) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} RGBA (Red, Green, Blue, Alpha) & rgba(255, 0, 0, 0.5) {\bf{(50\% transparent red)}} \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} HSLA (Hue, Saturated, Lightness, Alpha) & hsla(0, 100\%, 50\%, 0.5) {\bf{(50\% transparent red)}} \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{Note:}} \newline The 'Alpha' value ranges from 0 (completely transparent) to 1 (completely opaque).} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.16 cm} x{5.84 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Text Styles}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{text-color} & Set the color of text \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{text-align} & Arrangement of text (e.g. left, right, center) \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{text-decoration} & (e.g. underline) \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{letter-spacing} & Spacing between each letter \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{word-spacing} & Spacing between each word \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.68 cm} x{4.32 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Background}} \tn % Row 0 \SetRowColor{LightBackground} background-color & background-image \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} background-size & background-position \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{background-repeat} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Transitions}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=40\}\} \seqsplit{transition-property} & Specifies CSS property (e.g. width) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{transition-timing-function} & Specifies speed curve of transition effect \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} transition-delay & Specifies a delay (in seconds) for transition effect. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{transition-duration} & Specifies the transition effect duration (in seconds) \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.976 cm} x{2.28 cm} x{3.344 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Table}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=30\}\}Table border & \{\{width=30\}\}boarder-collapse & Sets whether the table borders should be collapsed into a single border \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} Table size & width, height & Sets width and height of table \tn % Row Count 7 (+ 2) % Row 2 \SetRowColor{LightBackground} Table alignment & text-align & Sets the horizontal alignment (left, right, or center) of the content in table \tn % Row Count 12 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Position}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{static} & Not affected by the top, bottom, left, and right properties \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{relative} & Positioned relative to its normal position \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} fixed & Always stays in the same place even if the page is scrolled \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{absolute} & Positioned relative to the nearest positioned ancestor \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{sticky} & Positioned based on the user's scroll position \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Box Model}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/tse-han_1735227385_images.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.2 cm} x{6.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Box Model Explanation}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Content} & Place for text and images appear \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{Padding} & Around the content where is transparent \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{Border} & Goes around the padding and content \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{Margins} & An area outside the border where is transparent \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.84 cm} x{4.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Margins \& Padding}} \tn % Row 0 \SetRowColor{LightBackground} Margins & Padding \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} margin-top & padding-top \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} margin-right & padding-right \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} margin-left & padding-left \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} margin-bottom & padding-bottom \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{EXTRA! (same concept for padding)}} \newline margin: 25px 50px 75px; \newline - top margin is 25px \newline - right and left margins are 50px \newline - bottom margin is 75px \newline \newline margin: 25px 50px; \newline - top and bottom margins are 25px \newline - right and left margins are 50px \newline \newline margin: 25px; \newline - all margins are 25px} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Border Style}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{border-style} & (e.g. dotted, dashed, solid) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{border-width} & Set border width \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{border-radius} & Set rounded border \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{border-color} & Set color of border \tn % Row Count 6 (+ 1) \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 Property Diagram}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/tse-han_1735229478_Screenshot 2024-12-27 000644.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Display Property}} \tn % Row 0 \SetRowColor{LightBackground} inline & Displays an element as an inline element \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} block & Displays an element as a block element \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{inline-block} & Displays an element as an inline-level block container \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} flex & Displays an element as a block-level flex container \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} grid & Displays an element as a block-level grid container \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}