[
  {
    "path": ".gitignore",
    "content": ".DS_Store"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 phuocng\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# CSS Layout\n\nAs a front-end engineer, I deal with a lot of layouts and components. While there are plenty of CSS frameworks out there that provide these, I don't always want to include them all in my project.\n\nThat's why I've put together a collection of the most popular layouts and components that can be built with pure CSS.\n\nThese layouts and components are powered by modern CSS features like flexbox and grid, and can be easily customized to fit your specific needs. By combining them, you can create any possible layout you need.\n\nThe best part? This collection has zero dependencies, no frameworks, and no CSS hacks. These are real use cases that can save you time and effort in your projects.\n\n## About\n\nThis project is developed by _Nguyen Huu Phuoc_. I love building products and sharing knowledge.\n\nBe my friend on\n\n-   [Twitter](https://twitter.com/nghuuphuoc)\n-   [Github](https://github.com/phuocng)\n"
  },
  {
    "path": "contents/accordion.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-04'\ndescription: Create an accordion with CSS flexbox\nkeywords: css accordion, css flexbox\nthumbnail: /assets/css-layout/thumbnails/accordion.png\ntitle: Accordion\n---\n\n## HTML\n\n```html index.html\n<!-- Container -->\n<div class=\"accordion\">\n    <!-- Collapsed item -->\n    <div class=\"accordion__item accordion__item--collapsed\">\n        <!-- Heading -->\n        <div class=\"accordion__header\">\n            <!-- The toggle icon -->\n            <div class=\"accordion__toggle\">...</div>\n\n            <!-- The title -->\n            <div class=\"accordion__title\">...</div>\n        </div>\n\n        <!-- The content -->\n        <div class=\"accordion__content\">...</div>\n    </div>\n\n    <!-- Expanded item -->\n    <div class=\"accordion__item accordion__item--expanded\">...</div>\n\n    <!-- Repeat other item -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.accordion {\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-bottom-color: transparent;\n    border-radius: 4px;\n}\n\n.accordion__item {\n    border-bottom: 1px solid #d1d5db;\n}\n\n.accordion__header {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n\n    cursor: pointer;\n    padding: 16px;\n}\n\n.accordion__toggle {\n    margin-right: 12px;\n}\n\n.accordion__title {\n    /* Take remaining width */\n    flex: 1;\n}\n\n.accordion__content {\n    border-top: 1px solid #d1d5db;\n    padding: 16px;\n}\n\n.accordion__item--collapsed .accordion__content {\n    display: none;\n}\n.accordion__item--expanded .accordion__content {\n    display: block;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\n.accordion {\n    border: 1px solid #d1d5db;\n    border-radius: 4px;\n    height: 100%;\n    width: 100%;\n}\n.accordion__item:not(:last-child) {\n    border-bottom: 1px solid #d1d5db;\n}\n.accordion__header {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    cursor: pointer;\n    padding: 0.5rem;\n}\n.accordion__toggle {\n    margin-right: 0.25rem;\n}\n.accordion__title {\n    flex: 1;\n}\n.accordion__content {\n    padding: 0.5rem;\n}\n\n.accordion__item--collapsed .accordion__content {\n    display: none;\n}\n.accordion__item--expanded .accordion__content {\n    display: block;\n}\n```\n\n```html index.html hidden\n<div class=\"accordion\">\n    <div class=\"accordion__item accordion__item--collapsed\">\n        <div class=\"accordion__header\">\n            <div class=\"accordion__toggle\">\n                <div class=\"triangle triangle--r triangle--sm\"></div>\n            </div>\n            <div class=\"accordion__title\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </div>\n        </div>\n    </div>\n    <div class=\"accordion__item accordion__item--expanded\">\n        <div class=\"accordion__header\">\n            <div class=\"accordion__toggle\">\n                <div class=\"triangle triangle--b triangle--sm\"></div>\n            </div>\n            <div class=\"accordion__title\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </div>\n        </div>\n        <div class=\"accordion__content\">\n            <div class=\"lines\">\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--100\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n\n            <div class=\"lines\">\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--100\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/arrow-buttons.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-21'\ndescription: Create arrow buttons with CSS\nkeywords: css arrow buttons\nthumbnail: /assets/css-layout/thumbnails/arrow-buttons.png\ntitle: Arrow buttons\nupdated: '2021-04-01'\n---\n\n## HTML\n\n```html index.html\n<!-- Up arrow button -->\n<button class=\"arrow-buttons\">\n    <!-- Arrow -->\n    <div class=\"arrow-button arrow-button--t\"></div>\n\n    <!-- Content -->\n    ...\n</button>\n\n<!-- Right arrow button -->\n<button class=\"arrow-buttons\">\n    <!-- Content -->\n    ...\n\n    <!-- Arrow -->\n    <div class=\"arrow-button arrow-button--r\"></div>\n</button>\n\n<!-- Down arrow button -->\n<button class=\"arrow-buttons\">\n    <!-- Arrow -->\n    <div class=\"arrow-button arrow-button--b\"></div>\n\n    <!-- Content -->\n    ...\n</button>\n\n<!-- Left arrow button -->\n<button class=\"arrow-buttons\">\n    <!-- Arrow -->\n    <div class=\"arrow-button arrow-button--l\"></div>\n\n    <!-- Content -->\n    ...\n</button>\n```\n\n## CSS\n\n```css styles.css\n.arrow-button {\n    /* Transparent background */\n    background-color: transparent;\n\n    /* Size */\n    height: 12px;\n    width: 12px;\n}\n\n.arrow-button--t {\n    /* Edges */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translateY(25%) rotate(45deg);\n}\n\n.arrow-button--r {\n    /* Edges */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translateX(-25%) rotate(45deg);\n}\n\n.arrow-button--b {\n    /* Edges */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translateY(-25%) rotate(45deg);\n}\n\n.arrow-button--l {\n    /* Edges */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translateX(25%) rotate(45deg);\n}\n```\n\n<Playground>\n```css styles.css hidden\n.arrow-buttons {\n    position: relative;\n    height: 100%;\n    width: 100%;\n}\n.arrow-button {\n    /* Transparent background */\n    background-color: transparent;\n\n    /* Size */\n    height: 12px;\n    width: 12px;\n}\n\n.arrow-button--t {\n    /* Edges */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translateY(25%) rotate(45deg);\n}\n\n.arrow-button--r {\n    /* Edges */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translateX(-25%) rotate(45deg);\n}\n\n.arrow-button--b {\n    /* Edges */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translateY(-25%) rotate(45deg);\n}\n\n.arrow-button--l {\n    /* Edges */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translateX(25%) rotate(45deg);\n}\n\n/* Demo */\n.arrow-buttons__corner {\n    position: absolute;\n}\n.arrow-buttons__corner--t {\n    left: 50%;\n    top: 0;\n    transform: translate(-50%, 0%);\n}\n.arrow-buttons__corner--r {\n    right: 0;\n    top: 50%;\n    transform: translate(0%, -50%);\n}\n.arrow-buttons__corner--b {\n    bottom: 0;\n    left: 50%;\n    transform: translate(-50%, 0%);\n}\n.arrow-buttons__corner--l {\n    left: 0;\n    top: 50%;\n    transform: translate(0%, -50%);\n}\n```\n\n```html index.html hidden\n<div class=\"arrow-buttons\">\n    <div class=\"arrow-buttons__corner arrow-buttons__corner--t\">\n        <div class=\"arrow-button arrow-button--t\"></div>\n    </div>\n    <div class=\"arrow-buttons__corner arrow-buttons__corner--r\">\n        <div class=\"arrow-button arrow-button--r\"></div>\n    </div>\n    <div class=\"arrow-buttons__corner arrow-buttons__corner--b\">\n        <div class=\"arrow-button arrow-button--b\"></div>\n    </div>\n    <div class=\"arrow-buttons__corner arrow-buttons__corner--l\">\n        <div class=\"arrow-button arrow-button--l\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/avatar-list.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-29'\ndescription: Create an avatar list with CSS flexbox\nkeywords: css avatar, css flexbox\nthumbnail: /assets/css-layout/thumbnails/avatar-list.png\ntitle: Avatar list\n---\n\n## HTML\n\n```html index.html\n<div class=\"avatars\">\n    <!-- Avatar item -->\n    <div class=\"avatars__item\">\n        <div class=\"avatars__image\">\n            <!-- Image -->\n            ...\n        </div>\n    </div>\n\n    <!-- Repeat other avatars -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.avatars {\n    display: flex;\n}\n\n.avatars__item {\n    /* Nagative margin make avatar overlap to previous one */\n    margin-left: -0.25rem;\n}\n\n.avatars__image {\n    /* Add a white curve between avatars */\n    box-shadow: 0 0 0 0.25rem #fff;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Rounded border */\n    border-radius: 9999px;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.avatars {\n    display: flex;\n    justify-content: center;\n\n    height: 2rem;\n    width: 100%;\n}\n.avatars__item {\n    margin-left: -0.25rem;\n}\n.avatars__image {\n    background-color: #d1d5db;\n    box-shadow: 0 0 0 0.25rem #fff;\n    color: #fff;\n    font-size: 0.75rem;\n\n    /* Rounded border */\n    border-radius: 50%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 2rem;\n    width: 2rem;\n}\n```\n\n```html index.html hidden\n<div class=\"avatars\">\n    <div class=\"avatars__item\">\n        <div class=\"avatars__image\">A</div>\n    </div>\n    <div class=\"avatars__item\">\n        <div class=\"avatars__image\">B</div>\n    </div>\n    <div class=\"avatars__item\">\n        <div class=\"avatars__image\">C</div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/avatar.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-04'\ndescription: Create an avatar component with CSS flexbox\nkeywords: css avatar, css flexbox\nthumbnail: /assets/css-layout/thumbnails/avatar.png\ntitle: Avatar\n---\n\n## HTML\n\n```html index.html\n<div class=\"avatar\">\n    <!-- Avatar image -->\n    <img class=\"avatar__image\" src=\"...\" />\n</div>\n```\n\n## CSS\n\n```css styles.css\n.avatar {\n    /* Rounded border */\n    border-radius: 50%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 4rem;\n    width: 4rem;\n}\n\n.avatar__image {\n    /* Size */\n    height: 50%;\n    width: 50%;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.avatar {\n    height: 4rem;\n    width: 4rem;\n\n    background-color: #d1d5db;\n    /* Rounded border */\n    border-radius: 50%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.avatar__image {\n    height: 50%;\n    width: 50%;\n}\n```\n\n```html index.html hidden\n<div class=\"avatar\">\n    <div class=\"avatar__image\">\n        <svg viewBox=\"0 0 24 24\" fill=\"none\" height=\"100%\" stroke=\"#FFF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1\" width=\"100%\">\n            <path d=\"M12,3.5c2.347,0,4.25,1.903,4.25,4.25S14.347,12,12,12s-4.25-1.903-4.25-4.25S9.653,3.5,12,3.5z M5,20.5 c0-3.866,3.134-7,7-7s7,3.134,7,7H5z\"></path>\n        </svg>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/badge.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-16'\ndescription: Create a badge component with CSS flexbox\nkeywords: css badge, css flexbox\nthumbnail: /assets/css-layout/thumbnails/badge.png\ntitle: Badge\n---\n\n## HTML\n\n```html index.html\n<div class=\"badge\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.badge {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Colors */\n    background-color: #d1d5db;\n    color: #fff;\n\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 3rem;\n    width: 3rem;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.badge {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Colors */\n    background-color: #d1d5db;\n    color: #fff;\n\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 3rem;\n    width: 3rem;\n}\n```\n\n```html index.html hidden\n<div class=\"badge\">9+</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/box-selector.mdx",
    "content": "---\ncategory: Input\ncreated: '2022-09-24'\ndescription: Create a box selector with CSS\nkeywords: css box selector\nthumbnail: /assets/css-layout/thumbnails/box-selector.png\ntitle: Box selector\n---\n\n## HTML\n\n```html index.html\n<div class=\"box-selector\">...</div>\n\n<!-- The selected variant -->\n<div class=\"box-selector box-selector--selected\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.box-selector {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.5rem;\n}\n\n.box-selector--selected {\n    /* Change the border color */\n    border: 2px solid #3b82f6;\n\n    /* Used to position the tick */\n    position: relative;\n}\n\n/* The tick */\n.box-selector--selected:before {\n    /* Absolute position */\n    content: '';\n    left: 0.25rem;\n    position: absolute;\n    top: 0.25rem;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    /* Background */\n    background-image: url(\"data:image/svg+xml,%3Csvg fill='%233b82f6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' %3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'%3E%3C/path%3E%3C/svg%3E\");\n    background-position: center center;\n    background-repeat: no-repeat;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.box-selector-container {\n    display: grid;\n    grid-template-columns: repeat(2, 1fr);\n    column-gap: 1rem;\n    row-gap: 1rem;\n    width: 16rem;\n}\n\n.box-selector {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.5rem;\n}\n\n.box-selector--selected {\n    border: 2px solid #3b82f6;\n    position: relative;\n\n    &:before {\n        content: '';\n        left: 0.25rem;\n        position: absolute;\n        top: 0.25rem;\n\n        height: 1rem;\n        width: 1rem;\n\n        background-image: url(\"data:image/svg+xml,%3Csvg fill='%233b82f6' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' %3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'%3E%3C/path%3E%3C/svg%3E\");\n        background-position: center center;\n        background-repeat: no-repeat;\n    }\n}\n```\n\n```html index.html hidden\n<div class=\"box-selector-container\">\n    <div class=\"box-selector box-selector--selected\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"box-selector\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"box-selector\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"box-selector\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Custom checkbox button](https://phuoc.ng/collection/css-layout/custom-checkbox-button/)\n-   [Custom radio button](https://phuoc.ng/collection/css-layout/custom-radio-button/)\n"
  },
  {
    "path": "contents/breadcrumb.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-17'\ndescription: Create a breadcrumb with CSS flexbox\nkeywords: css breadcrumb, css flexbox\nthumbnail: /assets/css-layout/thumbnails/breadcrumb.png\ntitle: Breadcrumb\n---\n\n## HTML\n\n```html index.html\n<div class=\"breadcrumb\">\n    <!-- Breadcrumb item -->\n    <div class=\"breadcrumb__item\">...</div>\n\n    <!-- Repeat other items -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.breadcrumb {\n    /* Content is centered vertically */\n    align-items: center;\n    display: flex;\n}\n\n.breadcrumb__item {\n    margin: 0 0.5rem;\n\n    /* Used to position the separator between items */\n    position: relative;\n}\n\n.breadcrumb__item:not(:last-child)::after {\n    /* Absolute position */\n    position: absolute;\n    right: 0;\n    top: 0;\n    transform: translate(0.5rem, 0px);\n\n    content: '/';\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.breadcrumb {\n    /* Content is centered vertically */\n    align-items: center;\n    display: flex;\n}\n\n.breadcrumb__item {\n    margin: 0 0.5rem;\n    position: relative;\n}\n\n.breadcrumb__item:not(:last-child)::after {\n    /* Absolute position */\n    position: absolute;\n    right: 0;\n    top: 0;\n    transform: translate(0.5rem, 0px);\n\n    content: '/';\n}\n```\n\n```html index.html hidden\n<div class=\"breadcrumb\">\n    <div class=\"breadcrumb__item\">A</div>\n    <div class=\"breadcrumb__item\">B</div>\n    <div class=\"breadcrumb__item\">C</div>\n    <div class=\"breadcrumb__item\">D</div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/button-with-icon.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-17'\ndescription: Create an icon button with CSS flexbox\nkeywords: css flexbox, css icon button\nthumbnail: /assets/css-layout/thumbnails/button-with-icon.png\ntitle: Button with icon\n---\n\n## HTML\n\n```html index.html\n<button class=\"button-with-icon\">\n    <!-- Icon -->\n    ...\n\n    <!-- Label -->\n    <div class=\"button-with-icon__label\">...</div>\n</button>\n```\n\n## CSS\n\n```css styles.css\n.button-with-icon {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: row;\n    justify-content: center;\n}\n\n.button-with-icon__label {\n    margin-left: 0.5rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.button-with-icon {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: row;\n    justify-content: center;\n\n    /* Demo */\n    background: #fff;\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    width: 8rem;\n}\n\n.button-with-icon__label {\n    flex: 1;\n    margin-left: 0.5rem;\n}\n```\n\n```html index.html hidden\n<button class=\"button-with-icon\">\n    <div class=\"circle circle--md\"></div>\n    <div class=\"button-with-icon__label\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n        </div>\n    </div>\n</button>\n```\n</Playground>\n"
  },
  {
    "path": "contents/calendar.mdx",
    "content": "---\ncategory: Display\ncreated: '2022-09-24'\ndescription: Create a calendar with CSS grid\nkeywords: css calendar, css grid\nthumbnail: /assets/css-layout/thumbnails/calendar.png\ntitle: Calendar\n---\n\n## HTML\n\n```html index.html\n<div class=\"calendar\">\n    <!-- Week days -->\n    <div class=\"calendar__weekday\">Mon</div>\n    <div class=\"calendar__weekday\">Tue</div>\n    <div class=\"calendar__weekday\">Wed</div>\n    <div class=\"calendar__weekday\">Thu</div>\n    <div class=\"calendar__weekday\">Fri</div>\n    <div class=\"calendar__weekday\">Sat</div>\n    <div class=\"calendar__weekday\">Sun</div>\n\n    <!-- Days of the previous month -->\n    <div class=\"calendar__day calendar__day--disabled\">30</div>\n    <div class=\"calendar__day calendar__day--disabled\">31</div>\n\n    <!-- Days of the current month -->\n    <div class=\"calendar__day\">1</div>\n    <div class=\"calendar__day\">2</div>\n\n    <!-- The current day -->\n    <div class=\"calendar__day calendar__day--current\">...</div>\n\n    <!-- Days of the next month -->\n    <div class=\"calendar__day calendar__day--disabled\">1</div>\n    <div class=\"calendar__day calendar__day--disabled\">2</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.calendar {\n    display: grid;\n    grid-template-columns: repeat(7, 1fr);\n}\n\n.calendar__weekday {\n    border-bottom: 1px solid #d1d5db;\n    padding: 0.125rem;\n}\n\n.calendar__day {\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    padding: 0.25rem;\n    text-align: center;\n}\n\n.calendar__day--current {\n    background-color: #3b82f6;\n    color: #fff;\n}\n\n.calendar__day:nth-child(7n + 1) {\n    border-left: 1px solid #d1d5db;\n}\n\n.calendar__day--disabled {\n    color: #d1d5db;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.calendar {\n    display: grid;\n    grid-template-columns: repeat(7, 1fr);\n    width: 16rem;\n}\n\n.calendar__weekday {\n    border-bottom: 1px solid #d1d5db;\n    padding: 0.5rem;\n    text-align: center;\n}\n\n.calendar__day {\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    padding: 0.5rem;\n    text-align: center;\n}\n\n.calendar__day--current {\n    background-color: #3b82f6;\n    color: #fff;\n}\n\n.calendar__day:nth-child(7n + 1) {\n    border-left: 1px solid #d1d5db;\n}\n\n.calendar__day--disabled {\n    color: #e5e7eb;\n}\n```\n\n```html index.html hidden\n<div class=\"calendar\">\n    <div class=\"calendar__weekday\">Mon</div>\n    <div class=\"calendar__weekday\">Tue</div>\n    <div class=\"calendar__weekday\">Wed</div>\n    <div class=\"calendar__weekday\">Thu</div>\n    <div class=\"calendar__weekday\">Fri</div>\n    <div class=\"calendar__weekday\">Sat</div>\n    <div class=\"calendar__weekday\">Sun</div>\n\n    <div class=\"calendar__day calendar__day--disabled\">29</div>\n    <div class=\"calendar__day calendar__day--disabled\">30</div>\n    <div class=\"calendar__day calendar__day--disabled\">31</div>\n\n    <div class=\"calendar__day\">1</div>\n    <div class=\"calendar__day\">2</div>\n    <div class=\"calendar__day\">3</div>\n    <div class=\"calendar__day\">4</div>\n    <div class=\"calendar__day\">5</div>\n    <div class=\"calendar__day\">6</div>\n    <div class=\"calendar__day\">7</div>\n    <div class=\"calendar__day\">8</div>\n    <div class=\"calendar__day\">9</div>\n    <div class=\"calendar__day\">10</div>\n\n    <div class=\"calendar__day\">11</div>\n    <div class=\"calendar__day\">12</div>\n    <div class=\"calendar__day\">13</div>\n    <div class=\"calendar__day\">14</div>\n    <div class=\"calendar__day\">15</div>\n    <div class=\"calendar__day\">16</div>\n    <div class=\"calendar__day\">17</div>\n    <div class=\"calendar__day\">18</div>\n    <div class=\"calendar__day\">19</div>\n    <div class=\"calendar__day\">20</div>\n\n    <div class=\"calendar__day\">21</div>\n    <div class=\"calendar__day\">22</div>\n    <div class=\"calendar__day calendar__day--current\">23</div>\n    <div class=\"calendar__day\">24</div>\n    <div class=\"calendar__day\">25</div>\n    <div class=\"calendar__day\">26</div>\n    <div class=\"calendar__day\">27</div>\n    <div class=\"calendar__day\">28</div>\n    <div class=\"calendar__day\">29</div>\n    <div class=\"calendar__day\">30</div>\n    <div class=\"calendar__day\">31</div>\n\n    <div class=\"calendar__day calendar__day--disabled\">1</div>\n    <div class=\"calendar__day calendar__day--disabled\">2</div>\n    <div class=\"calendar__day calendar__day--disabled\">3</div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/card-layout.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-12-25'\ndescription: Create a card layout with CSS flexbox\nkeywords: css card layout, css flexbox, css layout\nthumbnail: /assets/css-layout/thumbnails/card-layout.png\ntitle: Card layout\n---\n\n## HTML\n\n```html index.html\n<div class=\"card-layout\">\n    <!-- A card with given width -->\n    <div class=\"card-layout__item\">...</div>\n\n    <!-- Repeat other cards -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.card-layout {\n    display: flex;\n\n    /* Put a card in the next row when previous cards take all width */\n    flex-wrap: wrap;\n\n    margin-left: -0.25rem;\n    margin-right: -0.25rem;\n}\n\n.card-layout__item {\n    /* There will be 3 cards per row */\n    flex-basis: 33.33333%;\n\n    padding-left: 0.25rem;\n    padding-right: 0.25rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.card-layout {\n    display: flex;\n\n    /* Put a card in the next row when previous cards take all width */\n    flex-wrap: wrap;\n\n    margin-left: -0.25rem;\n    margin-right: -0.25rem;\n}\n\n.card-layout__item {\n    /* There will be 3 cards per row */\n    flex-basis: 33.33333%;\n\n    padding-left: 0.25rem;\n    padding-right: 0.25rem;\n\n    /* Demo */\n    margin: 0.25rem 0;\n}\n```\n\n```html index.html hidden\n<div class=\"card-layout\">\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"card-layout__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/card.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-17'\ndescription: Create a card with CSS flexbox\nkeywords: css card, css flexbox\nthumbnail: /assets/css-layout/thumbnails/card.png\ntitle: Card\n---\n\n## HTML\n\n```html index.html\n<div class=\"card\">\n    <!-- Cover -->\n    <div class=\"card__cover\">...</div>\n\n    <!-- Content -->\n    <div class=\"card__content\">...</div>\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.card {\n    display: flex;\n    flex-direction: column;\n}\n\n.card__cover {\n    height: 20rem;\n    width: 100%;\n}\n\n.card__content {\n    /* Take available height */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.card {\n    display: flex;\n    flex-direction: column;\n    width: 16rem;\n    height: 100%;\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n}\n.card__cover {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: 40%;\n    width: 100%;\n}\n.card__content {\n    /* Take available height */\n    flex: 1;\n    padding: 0.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"card\">\n    <div class=\"card__cover\">\n    </div>\n    <div class=\"card__content\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/carousel-slider.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2023-10-14'\ndescription: Create a carousel slider with CSS\nopenGraphCover: /og/css-layout/carousel-slider.png\nthumbnail: /assets/css-layout/thumbnails/carousel-slider.png\ntitle: Carousel slider\n---\n\nA carousel slider is a component that lets users browse a collection of items, usually images or cards, by sliding them horizontally or vertically. It's commonly used in websites and mobile apps to showcase products, features, or news articles.\n\nYou can find carousel sliders in all kinds of websites and apps, like e-commerce platforms, news portals, and social media sites. They offer an interactive and engaging way for users to navigate content without taking up too much screen space.\n\nOn top of that, carousel sliders can be customized with different transition effects, autoplay options, and navigation controls. This makes for an even better user experience.\n\nIn this post, we'll show you how to create a carousel slider with CSS.\n\n## HTML markup\n\nLet's talk about organizing the markup for a slider with five items. The slider consists of a `div` element with the class `slider__inner` that displays the list of items, each with a `slider__item` class.\n\n```html\n<div class=\"slider\">\n    <div class=\"slide__inner\">\n        <div class=\"slider__item\"></div>\n        <div class=\"slider__item\"></div>\n        <div class=\"slider__item\"></div>\n        <div class=\"slider__item\"></div>\n        <div class=\"slider__item\"></div>\n    </div>\n</div>\n```\n\nFor simplicity, let's assume all slider items have the same dimensions as the slider container. The `.slider` class sets the dimensions of the slider container to a `width` and `height` of 100%, taking up all available space in its parent element. The `overflow` property is set to `hidden` to ensure that any content that overflows the slider container is not visible.\n\n```css\n.slider {\n    overflow: hidden;\n    position: relative;\n    width: 100%;\n    height: 20rem;\n}\n```\n\nMeanwhile, the `.slider__inner` class positions the list of items inside the slider container. It has an absolute position with `top` and `left` properties set to 0, placing it at the top left corner of its parent element (the slider container). The `width` and `height` are also set to 100%, filling up all available space inside its parent element.\n\n```css\n.slide__inner {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n}\n```\n\nTo position the items inside the slider container, we use absolute positioning with `top`, `left`, `width`, and `height` properties set to 0 and 100% respectively, ensuring that each item takes up all available space inside the slider container.\n\n```css\n.slider__item {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n}\n```\n\nNow, to achieve the sliding effect, we use the `translateX()` function of CSS `transform` property. This function moves an element horizontally by a given percentage or pixel value. In our case, we want to move each item to the right so that only one item is visible at a time.\n\n```html\n<div class=\"slider__item\" style=\"transform: translateX(0%)\">1</div>\n<div class=\"slider__item\" style=\"transform: translateX(100%)\">2</div>\n<div class=\"slider__item\" style=\"transform: translateX(200%)\">3</div>\n<div class=\"slider__item\" style=\"transform: translateX(300%)\">4</div>\n<div class=\"slider__item\" style=\"transform: translateX(400%)\">5</div>\n```\n\nTo activate a specific item in the carousel slider, we shift the whole inner container to the left by a value that moves the target item into view. One way to achieve this is by setting the `transform` property of the `.slider__inner` element to `translateX(-300%)`. This will move the inner container three times its width to the left, which positions the fourth item at the beginning of the slider.\n\n```html\n<div class=\"slider__inner\" style=\"transform: translateX(-300%)\">\n    <div class=\"slider__item\" style=\"transform: translateX(0%)\">1</div>\n    <div class=\"slider__item\" style=\"transform: translateX(100%)\">2</div>\n    <div class=\"slider__item\" style=\"transform: translateX(200%)\">3</div>\n    <div class=\"slider__item\" style=\"transform: translateX(300%)\">4</div>\n    <div class=\"slider__item\" style=\"transform: translateX(400%)\">5</div>\n</div>\n```\n\nBy adjusting this value, we can easily activate any other item in our carousel slider. This technique allows us to create an interactive and engaging carousel slider that users can navigate through with ease.\n\n## Adding navigation\n\nNow that we have placed the slider items in the right spot, it's time to add navigation so users can easily move between them.\n\nTo do this, we'll create an additional element with the `slider__navigation` CSS class. This element contains multiple dots that users can click to jump to the corresponding item.\n\nHere is the updated markup:\n\n```html\n<div class=\"slider\">\n    <div class=\"slider__items\">\n        <!-- Slider items go here -->\n    </div>\n\n    <div class=\"slider__navigation\">\n        <div class=\"slider__dot\"></div>\n        <div class=\"slider__dot\"></div>\n        <div class=\"slider__dot\"></div>\n        <!-- Add more dots as needed -->\n    </div>\n</div>\n```\n\nThe `slider__navigation` element has a position of `absolute`, which means it's positioned relative to the nearest positioned ancestor (in this case, the `.slider` element). We set `bottom: 1rem` to position it at the bottom of the slider container, and `left: 50%` is used to center it horizontally.\n\nTo center its content horizontally, we use `transform: translateX(-50%)`, which moves it left by half of its own width.\n\n```css\n.slider__navigation {\n    position: absolute;\n    bottom: 1rem;\n    left: 50%;\n    transform: translateX(-50%);\n}\n```\n\nThe navigation dots inside the `slider__navigation` are created using individual elements with a class of `slider__dot`. To space them out evenly, we use the CSS property `gap: 0.5rem`, which adds a gap between each item. The items are aligned along the horizontal axis using flexbox properties such as `display: flex`, `align-items: center`, and `justify-content: center`.\n\n```css\n.slider__navigation {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    gap: 0.5rem;\n}\n```\n\nThe `slider__dot` class is used to style the navigation dots inside the `slider__navigation` element. It has a background color of `rgb(203 213 225)` and a border radius of `50%`, which gives it a circular shape. It also has a `cursor` property set to `pointer`, which changes the mouse cursor when hovering over the element, indicating that it can be clicked. Finally, its dimensions are set to `height: 0.5rem` and `width: 0.5rem`, making it small enough to fit inside the navigation container but large enough to be clickable.\n\n```css\n.slider__dot {\n    background-color: rgb(203 213 225);\n    border-radius: 50%;\n    cursor: pointer;\n\n    height: 0.5rem;\n    width: 0.5rem;\n}\n```\n\nTo indicate the currently active dot, we can add a separate class named `slider__dot--active` and apply it to the corresponding dot element. This class will have a different background color than the inactive dots, making it clear which item is currently active.\n\n```css\n.slider__dot--active {\n    background-color: rgb(100 116 139);\n}\n```\n\nWhen an item is activated in the slider, we can remove the `slider__dot--active` class from all dots and then add it only to the dot that corresponds to the currently active item. This ensures that only one dot is highlighted at any given time.\n\n## Adding arrows for easy navigation\n\nIn addition to the navigation we created earlier, we can further enhance the user experience by adding two buttons that allow users to quickly move to the previous and next items.\n\nHere's the updated markup:\n\n```html\n<div class=\"slider\">\n    ...\n    <div class=\"slider__prev\"></div>\n    <div class=\"slider__next\"></div>\n</div>\n```\n\nTo create these buttons, we use the `.slider__prev` and `.slider__next` classes. We set their position to absolute so that they're positioned relative to the slider container. We also set the top position to `50%` and use `transform: translateY(-50%)` to center them vertically inside the slider container.\n\nHere's how they are positioned:\n\n```css\n.slider__prev,\n.slider__next {\n    position: absolute;\n    top: 50%;\n    transform: translateY(-50%);\n\n    height: 1rem;\n    width: 0.5rem;\n}\n```\n\nTo add arrow navigation to the carousel slider, we can use CSS pseudo-elements `::before` and `::after`. These elements allow us to add content before or after an element's content, which in our case will be arrows.\n\nIf you're not familiar with how to create arrows using CSS, you can check out this [post](https://phuoc.ng/collection/css-layout/triangle-buttons/) for guidance.\n\nWith these CSS rules in place, you should now have fully functional arrow navigation for your carousel slider.&#x20;\n\n## Demo\n\nLet's take a look at the final result. Check out the code to see how we shifted the whole inner element to activate the fourth item. It's important to note that this is purely for layout purposes only. Clicking on the dots or arrows won't navigate to the corresponding item. Check out this [post](https://phuoc.ng/collection/css-animation/navigate-to-a-specific-item-in-a-carousel-slider/) to learn how we can make it happen.\n\n<Playground>\n```css styles.css\n.slider {\n    overflow: hidden;\n    position: relative;\n    width: 100%;\n    height: 20rem;\n}\n.slider__inner {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n}\n.slider__item {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n\n    /* Demo purpose */\n    background: rgb(241 245 249);\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    font-size: 2.5rem;\n    font-weight: 500;\n}\n.slider__navigation {\n    position: absolute;\n    bottom: 1rem;\n    left: 50%;\n    transform: translateX(-50%);\n\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    gap: 0.5rem;\n}\n.slider__dot {\n    background: rgb(203 213 225);\n    border-radius: 50%;\n    cursor: pointer;\n\n    height: 0.5rem;\n    width: 0.5rem;\n}\n.slider__dot--active {\n    background: rgb(100 116 139);\n}\n\n.slider__prev,\n.slider__next {\n    position: absolute;\n    top: 50%;\n    transform: translateY(-50%);\n    height: 1rem;\n    width: 0.5rem;\n}\n.slider__prev::before,\n.slider__next::before {\n    cursor: pointer;\n    content: '';\n    position: absolute;\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.slider__prev::before {\n    border-color: transparent rgb(148 163 184) transparent transparent;\n    border-width: 0.5rem 0.5rem 0.5rem 0;\n}\n.slider__next::before {\n    border-color: transparent transparent transparent rgb(148 163 184);\n    border-width: 0.5rem 0 0.5rem 0.5rem;\n}\n.slider__prev {\n    left: 0.5rem;\n}\n.slider__next {\n    right: 0.5rem;\n}\n```\n\n```html index.html\n<div class=\"slider\">\n    <div class=\"slider__inner\" style=\"transform: translateX(-300%)\">\n        <div class=\"slider__item\" style=\"transform: translateX(0%)\">1</div>\n        <div class=\"slider__item\" style=\"transform: translateX(100%)\">2</div>\n        <div class=\"slider__item\" style=\"transform: translateX(200%)\">3</div>\n        <div class=\"slider__item\" style=\"transform: translateX(300%)\">4</div>\n        <div class=\"slider__item\" style=\"transform: translateX(400%)\">5</div>\n    </div>\n\n    <div class=\"slider__navigation\">\n        <div class=\"slider__dot\"></div>\n        <div class=\"slider__dot\"></div>\n        <div class=\"slider__dot\"></div>\n        <div class=\"slider__dot slider__dot--active\"></div>\n        <div class=\"slider__dot\"></div>\n    </div>\n\n    <div class=\"slider__prev\"></div>\n    <div class=\"slider__next\"></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Dot navigation](https://phuoc.ng/collection/css-layout/dot-navigation/)\n-   [Fixed at side](https://phuoc.ng/collection/css-layout/fixed-at-side/)\n-   [Navigate to a specific item in a carousel slider](https://phuoc.ng/collection/css-animation/navigate-to-a-specific-item-in-a-carousel-slider/)\n-   [Triangle buttons](https://phuoc.ng/collection/css-layout/triangle-buttons/)\n"
  },
  {
    "path": "contents/center-align-one-and-left-align-the-other.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-08-27'\ndescription: How to center align one element and left align the other\nkeywords: css flexbox, css grid\nopenGraphCover: /og/css-layout/center-align-one-left-align-other.png\nthumbnail: /assets/css-layout/thumbnails/center-align-one-left-align-other.png\ntitle: Center align one and left align the other\n---\n\nUsing a single row to display all elements is a common pattern in web design. These elements can be divided into different groups and arranged on the left, center, or right side of the row.\n\nYou've probably seen this pattern before, like in a toolbar where the main actions are grouped and displayed at the center. Meanwhile, less important buttons are located on the left side, like a button to toggle the sidebar.\n\nAnother example is the header of a web application, where the main title is displayed at the center, and a button to go back to the previous page is on the left side.\n\nIn this post, we'll learn how to create this kind of layout. To keep it simple, let's assume that the layout consists of only two elements.\n\n```html\n<div class=\"container\">\n    <div class=\"container__left\"></div>\n    <div class=\"container__center\"></div>\n</div>\n```\n\n## Using CSS flexbox\n\nInitially, our first idea might be to use flexbox to arrange the layout.\n\n```css\n.container {\n  display: flex;\n  justify-content: center;\n}\n```\n\nTo align the first element to the left and center the remaining items, we can use the margin property. Here's an example:\n\n```css\n.container__left {\n    margin-right: auto;\n}\n.container__center {\n    margin-right: auto;\n}\n```\n\nLet's take a look at what it looks like:\n\n<Playground>\n```css demo.css hidden\n:root {\n    --placeholder-size: 1rem;\n}\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.circle {\n    background-color: rgb(203 213 225);\n    border-radius: 9999px;\n    height: var(--placeholder-size);\n    width: var(--placeholder-size);\n    margin-right: 0.125rem;\n}\n.square {\n    background-color: rgb(203 213 225);\n    border-radius: 0.25rem;\n    height: var(--placeholder-size);\n    width: var(--placeholder-size);\n    margin: 0 0.125rem;\n}\n.container {\n    border: 1px solid rgb(203 213 225);\n    border-radius: 0.25rem;\n    padding: 0.5rem;\n    width: 16rem;\n}\n.container__left,\n.container__center {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.container {\n    display: flex;\n}\n.container__left {\n    margin-right: auto;\n}\n.container__center {\n    margin-right: auto;\n}\n```\n\n```html index.html\n<div class=\"container\">\n    <div class=\"container__left\">\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n    </div>\n    <div class=\"container__center\">\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n    </div>\n</div>\n```\n</Playground>\n\nUnfortunately, our expectation doesn't match reality. The main element is centered only within the available space, not the entire container. Let's move on to the next section to find a solution to this issue.\n\n## Using CSS grid\n\nIn addition to CSS flexbox, CSS offers another powerful tool for creating layouts: CSS grid. We can use this technique to solve the issue we talked about earlier.\n\nLet's say we now have three elements in our layout instead of two, and we need to add an empty element on the right-hand side.\n\n```css\n.container {\n    display: grid;\n    grid-template-columns: 1fr repeat(1, auto) 1fr;\n}\n```\n\nLet's dive into some CSS talk. The first CSS declaration is simple: it replaces the `flex` value with `grid`, which tells the browser to create a grid layout.\n\nNow, the second CSS declaration might seem confusing, but it's actually quite easy to understand. The `1fr` means that the first and last columns should take up an equal amount of space. The `repeat(1, auto)` declaration means that there should be one column with a width of `auto`.\n\nSo, in simpler terms, this CSS declaration creates a layout with three columns. The first and last columns will have equal width, while the middle column will adjust its width to fit its content.\n\nLastly, we want the main element to start at the second column. So, we can set the `grid-column-start` property to 2.\n\n```css\n.container__center {\n    grid-column-start: 2;\n}\n```\n\nNow, it's a breeze to move the first column to the left.\n\n```css\n.container__left {\n    margin-right: auto;\n}\n```\n\nFinally, let's check out the demonstration to see the progress we've made so far!\n\n<Playground>\n```css demo.css hidden\n:root {\n    --placeholder-size: 1rem;\n}\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.circle {\n    background-color: rgb(203 213 225);\n    border-radius: 9999px;\n    height: var(--placeholder-size);\n    width: var(--placeholder-size);\n    margin-right: 0.125rem;\n}\n.square {\n    background-color: rgb(203 213 225);\n    border-radius: 0.25rem;\n    height: var(--placeholder-size);\n    width: var(--placeholder-size);\n    margin: 0 0.125rem;\n}\n.container {\n    border: 1px solid rgb(203 213 225);\n    border-radius: 0.25rem;\n    padding: 0.5rem;\n    width: 16rem;\n}\n.container__left,\n.container__center {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.container {\n    display: grid;\n    grid-template-columns: 1fr repeat(1, auto) 1fr;\n}\n.container__left {\n    margin-right: auto;\n}\n.container__center {\n    grid-column-start: 2;\n}\n```\n\n```html index.html\n<div class=\"container\">\n    <div class=\"container__left\">\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n    </div>\n    <div class=\"container__center\">\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n    </div>\n</div>\n```\n</Playground>\n\nReplacing the non-existing third column with the real one is a piece of cake. All you need to do is push it to the right using a single CSS declaration.\n\n```css\n.container__right {\n    margin-left: auto;\n}\n```\n\n<Playground>\n```css demo.css hidden\n:root {\n    --placeholder-size: 1rem;\n}\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.circle {\n    background-color: rgb(203 213 225);\n    border-radius: 9999px;\n    height: var(--placeholder-size);\n    width: var(--placeholder-size);\n    margin-right: 0.125rem;\n}\n.square {\n    background-color: rgb(203 213 225);\n    border-radius: 0.25rem;\n    height: var(--placeholder-size);\n    width: var(--placeholder-size);\n    margin: 0 0.125rem;\n}\n.container {\n    border: 1px solid rgb(203 213 225);\n    border-radius: 0.25rem;\n    padding: 0.5rem;\n    width: 16rem;\n}\n.container__left,\n.container__center,\n.container__right {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css hidden\n.container {\n    display: grid;\n    grid-template-columns: 1fr repeat(1, auto) 1fr;\n}\n.container__left {\n    margin-right: auto;\n}\n.container__center {\n    grid-column-start: 2;\n}\n.container__right {\n    margin-left: auto;\n}\n```\n\n```html index.html hidden\n<div class=\"container\">\n    <div class=\"container__left\">\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n    </div>\n    <div class=\"container__center\">\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n        <div class=\"square\"></div>\n    </div>\n    <div class=\"container__right\">\n        <div class=\"circle\"></div>\n        <div class=\"circle\"></div>\n    </div>\n</div>\n```\n</Playground>\n\n## Usages\n\nIn addition to the sample usages mentioned earlier, I've been using this technique to create a layout that centers the main content of the page while aligning the sidebar to the right side of the screen.\n\nHere's an example of what the layout looks like:\n\n<Playground>\n```css demo.css hidden\n.container {\n    border: 1px solid rgb(203 213 225);\n    width: 100%;\n    height: 16rem;\n}\n.container__main {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    background: rgb(203 213 225);\n    width: 9rem;\n}\n.container__sidebar {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    background: rgb(226 232 240);\n    width: 4rem;\n}\n@media (min-width: 600px) {\n    .container__main {\n        width: 15rem;\n    }\n    .container__sidebar {\n        width: 8rem;\n    }\n}\n```\n\n```css styles.css\n.container {\n    display: grid;\n    grid-template-columns: 1fr repeat(1, auto) 1fr;\n}\n.container__main {\n    grid-column-start: 2;\n}\n.container__sidebar {\n    margin-left: auto;\n}\n```\n\n```html index.html\n<div class=\"container\">\n    <div class=\"container__main\">Main</div>\n    <div class=\"container__sidebar\">Sidebar</div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/centering.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-15'\ndescription: Center an element with CSS flexbox\nkeywords: css centering, css flexbox\nthumbnail: /assets/css-layout/thumbnails/centering.png\ntitle: Centering\n---\n\n## HTML\n\n```html index.html\n<div class=\"centering\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.centering {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.centering {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Demo */\n    flex-direction: column;\n    width: 16rem;\n}\n```\n\n```html index.html hidden\n<div class=\"centering\">\n    <div class=\"circle circle--md\"></div>\n    <div class=\"lines\">\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n        <div class=\"line line--100\"></div>\n        <div class=\"line line--60\"></div>\n        <div class=\"line line--20\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/chip.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-12-21'\ndescription: Create a chip component with CSS flexbox\nkeywords: css chip, css flexbox, css tag\nthumbnail: /assets/css-layout/thumbnails/chip.png\ntitle: Chip\n---\n\n## HTML\n\n```html index.html\n<div class=\"chip\">\n    <!-- Content -->\n    <div class=\"chip__content\">...</div>\n\n    <!-- The close button -->\n    <button class=\"chip__button\">\n        <div class=\"chip__button-line chip__button-line--first\"></div>\n        <div class=\"chip__button-line chip__button-line--second\"></div>\n    </button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.chip {\n    /* Center the content */\n    align-items: center;\n    display: inline-flex;\n    justify-content: center;\n\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Spacing */\n    padding: 0.25rem 0.5rem;\n}\n\n.chip__content {\n    margin-right: 0.25rem;\n}\n```\n\nThe [close button](https://phuoc.ng/collection/css-layout/close-button/) is used to create a button for removing the chip:\n\n```css\n.chip__button {\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    /* Used to position the inner */\n    position: relative;\n}\n\n.chip__button-line {\n    /* Background color */\n    background-color: #9ca3af;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.chip__button-line--first {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.chip__button-line--second {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.chip {\n    /* Center the content */\n    align-items: center;\n    display: inline-flex;\n    justify-content: center;\n\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Spacing */\n    padding: 0.25rem 0.5rem;\n}\n\n.chip__content {\n    margin-right: 0.25rem;\n}\n\n.chip__button {\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    /* Used to position the inner */\n    position: relative;\n}\n\n.chip__button-line {\n    /* Background color */\n    background-color: #9ca3af;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.chip__button-line--first {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.chip__button-line--second {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n```html index.html hidden\n<div class=\"chip\">\n    <div class=\"chip__content\">CSS</div>\n    <button class=\"chip__button\">\n        <div class=\"chip__button-line chip__button-line--first\"></div>\n        <div class=\"chip__button-line chip__button-line--second\"></div>\n    </button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/circular-navigation.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-30'\ndescription: Create a circular navigation with CSS flexbox\nkeywords: css circular navigation, css flexbox\nthumbnail: /assets/css-layout/thumbnails/circular-navigation.png\ntitle: Circular navigation\n---\n\n## HTML\n\n```html index.html\n<div class=\"circular-navigation\">\n    <!-- The trigger element that will show all circles when user clicks it -->\n    ...\n\n    <!-- A circle menu item -->\n    <div class=\"circular-navigation__circle\">\n        <!-- The content -->\n        <div class=\"circular-navigation__content\">...</div>\n    </div>\n\n    <!-- Repeat menu items -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.circular-navigation {\n    position: relative;\n}\n\n.circular-navigation__circle {\n    /* Position */\n    position: absolute;\n    top: 0;\n\n    /*\n    3rem is the distance from the item to the trigger element.\n    Replace 0deg with 60deg, 180deg, 240deg, 300deg for another item\n    in case you want to have a total of 6 menu items.\n    The formulation is 360 / numberOfItems * indexOfItem\n    */\n    transform: rotate(0deg) translateX(-3rem);\n\n    /* Must have the same size as the trigger element */\n    height: 2rem;\n    width: 2rem;\n}\n\n.circular-navigation__content {\n    /*\n    Rotate it to make it displayed vertically\n    Replace -0deg with -60deg, -180deg, -240deg, -300deg for another item\n    in case you want to have a total of 6 menu items.\n    The formulation is -(360 / numberOfItems * indexOfItem)\n    */\n    transform: rotate(-0deg);\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.circular-navigation-container {\n    /* Demo */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    height: 8rem;\n    width: 8rem;\n}\n\n.circular-navigation {\n    position: relative;\n    height: 2rem;\n    width: 2rem;\n}\n\n.circular-navigation__circle {\n    /* Position */\n    position: absolute;\n    top: 0;\n\n    /*\n    3rem is the distance from the item to the trigger element.\n    Replace 0deg with 60deg, 180deg, 240deg, 300deg for another item\n    in case you want to have a total of 6 menu items.\n    The formulation is 360 / numberOfItems * indexOfItem\n    */\n    transform: rotate(var(--circular-navigation__circle-degree)) translateX(-3rem);\n\n    /* Must have the same size as the trigger element */\n    height: 2rem;\n    width: 2rem;\n\n    /* Demo */\n    background-color: #d1d5db;\n    border-radius: 9999px;\n}\n\n.circular-navigation__content {\n    /*\n    Rotate it to make it displayed vertically\n    Replace -0deg with -60deg, -180deg, -240deg, -300deg for another item\n    in case you want to have a total of 6 menu items.\n    The formulation is -(360 / numberOfItems * indexOfItem)\n    */\n    transform: rotate(var(--circular-navigation__content-degree));\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n}\n\n.circular-navigation__circle--1 {\n    --circular-navigation__circle-degree: 0deg;\n    --circular-navigation__content-degree: -0deg;\n}\n.circular-navigation__circle--2 {\n    --circular-navigation__circle-degree: 60deg;\n    --circular-navigation__content-degree: -60deg;\n}\n.circular-navigation__circle--3 {\n    --circular-navigation__circle-degree: 120deg;\n    --circular-navigation__content-degree: -120deg;\n}\n.circular-navigation__circle--4 {\n    --circular-navigation__circle-degree: 180deg;\n    --circular-navigation__content-degree: -180deg;\n}\n.circular-navigation__circle--5 {\n    --circular-navigation__circle-degree: 240deg;\n    --circular-navigation__content-degree: -240deg;\n}\n.circular-navigation__circle--6 {\n    --circular-navigation__circle-degree: 300deg;\n    --circular-navigation__content-degree: -300deg;\n}\n```\n\n```html index.html hidden\n<div class=\"circular-navigation-container\">\n    <div class=\"circular-navigation\">\n        <div class=\"circular-navigation__circle circular-navigation__circle--1\">\n            <div class=\"circular-navigation__content\">1</div>\n        </div>\n        <div class=\"circular-navigation__circle circular-navigation__circle--2\">\n            <div class=\"circular-navigation__content\">2</div>\n        </div>\n        <div class=\"circular-navigation__circle circular-navigation__circle--3\">\n            <div class=\"circular-navigation__content\">3</div>\n        </div>\n        <div class=\"circular-navigation__circle circular-navigation__circle--4\">\n            <div class=\"circular-navigation__content\">4</div>\n        </div>\n        <div class=\"circular-navigation__circle circular-navigation__circle--5\">\n            <div class=\"circular-navigation__content\">5</div>\n        </div>\n        <div class=\"circular-navigation__circle circular-navigation__circle--6\">\n            <div class=\"circular-navigation__content\">6</div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/close-button.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-11'\ndescription: Create a close button with CSS flexbox\nkeywords: css close button, css flexbox\nthumbnail: /assets/css-layout/thumbnails/close-button.png\ntitle: Close button\n---\n\n## HTML\n\n```html index.html\n<button class=\"close-button\">\n    <div class=\"close-button__line close-button__line--first\"></div>\n    <div class=\"close-button__line close-button__line--second\"></div>\n</button>\n```\n\n## CSS\n\n```css styles.css\n.close-button {\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 3rem;\n    width: 3rem;\n\n    /* Used to position the inner */\n    position: relative;\n}\n\n.close-button__line {\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.close-button__line--first {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.close-button__line--second {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.close-button {\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 3rem;\n    width: 3rem;\n\n    /* Used to position the inner */\n    position: relative;\n}\n\n.close-button__line {\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.close-button__line--first {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.close-button__line--second {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n```html index.html hidden\n<button class=\"close-button\">\n    <div class=\"close-button__line close-button__line--first\"></div>\n    <div class=\"close-button__line close-button__line--second\"></div>\n</button>\n```\n</Playground>\n"
  },
  {
    "path": "contents/color-swatch.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-05-08'\ndescription: Create a color swatch with CSS flexbox\nkeywords: css color swatch, css flexbox\nthumbnail: /assets/css-layout/thumbnails/color-swatch.png\ntitle: Color swatch\n---\n\n## HTML\n\n```html index.html\n<div class=\"swatch\">\n    <div class=\"swatch__item\" style=\"background-color: ...\"></div>\n\n    <!-- Repeat other items -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.swatch {\n    /* Wrap the items */\n    display: flex;\n    flex-wrap: wrap;\n}\n.swatch__item {\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 1.5rem;\n    width: 1.5rem;\n\n    /* Space between items */\n    margin: 0.5rem;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.swatch {\n    /* Wrap the items */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-wrap: wrap;\n}\n.swatch__item {\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 1.5rem;\n    width: 1.5rem;\n\n    /* Space between items */\n    margin: 0.5rem;\n}\n.swatch__item--1st {\n    background-color: rgba(0, 0, 0, 0.1);\n}\n.swatch__item--2nd {\n    background-color: rgba(0, 0, 0, 0.2);\n}\n.swatch__item--3rd {\n    background-color: #d1d5db;\n}\n.swatch__item--4th {\n    background-color: rgba(0, 0, 0, 0.4);\n}\n.swatch__item--5th {\n    background-color: rgba(0, 0, 0, 0.5);\n}\n.swatch__item--6th {\n    background-color: rgba(0, 0, 0, 0.6);\n}\n```\n\n```html index.html hidden\n<div class=\"swatch\">\n    <div class=\"swatch__item swatch__item--1st\"></div>\n    <div class=\"swatch__item swatch__item--2nd\"></div>\n    <div class=\"swatch__item swatch__item--3rd\"></div>\n    <div class=\"swatch__item swatch__item--4th\"></div>\n    <div class=\"swatch__item swatch__item--5th\"></div>\n    <div class=\"swatch__item swatch__item--6th\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/concave-corners.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-05-09'\ndescription: Create concave corners with CSS\nkeywords: css border radius, css concave border radius, css concave corners\nthumbnail: /assets/css-layout/thumbnails/concave-corners.png\ntitle: Concave corners\n---\n\n## HTML\n\n```html index.html\n<div class=\"concave-corners\">\n    <!-- The top-left corner -->\n    <div class=\"concave-corners__corner concave-corners__corner--tl\"></div>\n\n    <!-- The top-right corner -->\n    <div class=\"concave-corners__corner concave-corners__corner--tr\"></div>\n\n    <!-- The bottom-left corner -->\n    <div class=\"concave-corners__corner concave-corners__corner--bl\"></div>\n\n    <!-- The bottom-right corner -->\n    <div class=\"concave-corners__corner concave-corners__corner--br\"></div>\n\n    <!-- Content -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.concave-corners {\n    background-color: #d1d5db;\n\n    /* Used to position the corners */\n    position: relative;\n}\n.concave-corners__corner {\n    /* Absolute position */\n    position: absolute;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    background: #fff;\n}\n\n.concave-corners__corner--tl {\n    /* Position */\n    left: 0;\n    top: 0;\n\n    /* Border radius */\n    border-radius: 0 0 1rem 0;\n}\n\n.concave-corners__corner--tr {\n    /* Position */\n    right: 0;\n    top: 0;\n\n    /* Border radius */\n    border-radius: 0 0 0 1rem;\n}\n\n.concave-corners__corner--bl {\n    /* Position */\n    bottom: 0;\n    left: 0;\n\n    /* Border radius */\n    border-radius: 0 1rem 0 0;\n}\n\n.concave-corners__corner--br {\n    /* Position */\n    bottom: 0;\n    right: 0;\n\n    /* Border radius */\n    border-radius: 1rem 0 0 0;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.concave-corners {\n    background-color: #d1d5db;\n\n    /* Used to position the corners */\n    position: relative;\n\n    /* Misc */\n    height: 100%;\n    width: 100%;\n}\n.concave-corners__corner {\n    /* Absolute position */\n    position: absolute;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    background: #fff;\n}\n\n.concave-corners__corner--tl {\n    /* Position */\n    left: 0;\n    top: 0;\n\n    /* Border radius */\n    border-radius: 0 0 1rem 0;\n}\n\n.concave-corners__corner--tr {\n    /* Position */\n    right: 0;\n    top: 0;\n\n    /* Border radius */\n    border-radius: 0 0 0 1rem;\n}\n\n.concave-corners__corner--bl {\n    /* Position */\n    bottom: 0;\n    left: 0;\n\n    /* Border radius */\n    border-radius: 0 1rem 0 0;\n}\n\n.concave-corners__corner--br {\n    /* Position */\n    bottom: 0;\n    right: 0;\n\n    /* Border radius */\n    border-radius: 1rem 0 0 0;\n}\n```\n\n```html index.html hidden\n<div class=\"concave-corners\">\n    <div class=\"concave-corners__corner concave-corners__corner--tl\"></div>\n    <div class=\"concave-corners__corner concave-corners__corner--tr\"></div>\n    <div class=\"concave-corners__corner concave-corners__corner--bl\"></div>\n    <div class=\"concave-corners__corner concave-corners__corner--br\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/cookie-banner.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-30'\ndescription: Create a cookie banner with CSS flexbox\nkeywords: css cookie banner, css flexbox\nthumbnail: /assets/css-layout/thumbnails/cookie-banner.png\ntitle: Cookie banner\n---\n\n## HTML\n\n```html index.html\n<div class=\"cookie-banner\">\n    <!-- Tells visitors that the website uses cookie -->\n    <div class=\"cookie-banner__content\">...</div>\n\n    <!-- Close button -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.cookie-banner {\n    /* Banner is displayed at the bottom */\n    bottom: 0;\n    left: 0;\n    position: fixed;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.cookie-banner__content {\n    /* Take available width */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.cookie-banner {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    height: 100%;\n    width: 100%;\n\n    align-items: end;\n    display: flex;\n}\n\n.cookie-banner__content {\n    border-top: 1px solid #d1d5db;\n    /* Take available width */\n    flex: 1;\n    padding: 0 0.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"cookie-banner\">\n    <div class=\"cookie-banner__content\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/corner-ribbon.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-01'\ndescription: Create a corner ribbon with CSS flexbox\nkeywords: css flexbox, css ribbon\nthumbnail: /assets/css-layout/thumbnails/corner-ribbon.png\ntitle: Corner ribbon\n---\n\n## HTML\n\n```html index.html\n<div class=\"corner-ribbon\">\n    <!-- The container -->\n    <div class=\"corner-ribbon__inner\">\n        <!-- The ribbon -->\n        <div class=\"corner-ribbon__ribbon\"></div>\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.corner-ribbon {\n    position: relative;\n}\n\n.corner-ribbon__inner {\n    /* Displayed at the top left corner */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Size */\n    height: 4rem;\n    width: 4rem;\n\n    /* Hide the part of its children which is displayed outside */\n    overflow: hidden;\n}\n\n.corner-ribbon__ribbon {\n    /* Position */\n    left: 1rem;\n    position: absolute;\n    top: 1rem;\n\n    /* Size */\n    height: 1.5rem;\n    width: 5.656rem;\n\n    /* Displayed diagonally */\n    transform: translate(-38px, -8px) rotate(-45deg);\n\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Centerize the text content */\n    text-align: center;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.corner-ribbon {\n    position: relative;\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n}\n\n.corner-ribbon__inner {\n    /* Displayed at the top left corner */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Size */\n    height: 4rem;\n    width: 4rem;\n\n    /* Hide the part of its children which is displayed outside */\n    overflow: hidden;\n}\n\n.corner-ribbon__ribbon {\n    /* Position */\n    left: 1rem;\n    position: absolute;\n    top: 1rem;\n\n    /* Size */\n    height: 1.5rem;\n    width: 5.656rem;\n\n    /* Displayed diagonally */\n    transform: translate(-38px, -8px) rotate(-45deg);\n\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Centerize the text content */\n    text-align: center;\n}\n```\n\n```html index.html hidden\n<div class=\"corner-ribbon\">\n    <div class=\"corner-ribbon__inner\">\n        <div class=\"corner-ribbon__ribbon\">\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/curved-background.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-17'\ndescription: Create an element with curved background\nkeywords: css border radius, css curved background\nthumbnail: /assets/css-layout/thumbnails/curved-background.png\ntitle: Curved background\n---\n\n## HTML\n\n```html index.html\n<div class=\"curved-background\">\n    <div class=\"curved-background__curved\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.curved-background__curved {\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* You can use gradient background color such as */\n    /* background: linear-gradient(rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.1) 100%); */\n\n    /* Curved corners */\n    border-bottom-left-radius: 50% 40%;\n    border-bottom-right-radius: 50% 40%;\n\n    /* Size */\n    height: 50%;\n    width: 100%;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.curved-background {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n}\n.curved-background__curved {\n    background-color: #d1d5db;\n    border-bottom-left-radius: 50% 40%;\n    border-bottom-right-radius: 50% 40%;\n\n    height: 8rem;\n    width: 100%;\n}\n```\n\n```html index.html hidden\n<div class=\"curved-background\">\n    <div class=\"curved-background__curved\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/custom-checkbox-button.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-12-01'\ndescription: Create a custom checkbox button with CSS flexbox\nkeywords: css checkbox, css flexbox\nthumbnail: /assets/css-layout/thumbnails/custom-checkbox-button.png\ntitle: Custom checkbox button\n---\n\n## HTML\n\n```html index.html\n<label class=\"custom-checkbox-button\">\n    <!-- The real checkbox -->\n    <input type=\"checkbox\" class=\"custom-checkbox-button__input\" />\n\n    <!-- The fake square -->\n    <div class=\"custom-checkbox-button__square\">\n        <!-- The inner square -->\n        <div class=\"custom-checkbox-button__checkbox custom-checkbox-button__checkbox--selected\"></div>\n    </div>\n\n    <!-- The text -->\n    ...\n</label>\n```\n\n## CSS\n\n```css styles.css\n.custom-checkbox-button {\n    /* Center the content horizontally */\n    align-items: center;\n    display: inline-flex;\n\n    /* Cursor */\n    cursor: pointer;\n}\n\n.custom-checkbox-button__input {\n    /* Hide it */\n    display: none;\n}\n\n.custom-checkbox-button__square {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Spacing */\n    margin-right: 0.5rem;\n    padding: 0.25rem;\n}\n\n.custom-checkbox-button__checkbox {\n    background-color: transparent;\n    border-radius: 0.25rem;\n    height: 1rem;\n    width: 1rem;\n}\n\n.custom-checkbox-button__checkbox--selected {\n    /* For selected checkbox */\n    background-color: #3b82f6;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.custom-checkbox-button {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Demo */\n    margin: 0.25rem 0;\n    width: 16rem;\n}\n\n.custom-checkbox-button__input {\n    /* Hide it */\n    display: none;\n}\n\n.custom-checkbox-button__square {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Spacing */\n    margin-right: 0.5rem;\n    padding: 0.25rem;\n}\n\n.custom-checkbox-button__checkbox {\n    background-color: transparent;\n    border-radius: 0.25rem;\n    height: 1rem;\n    width: 1rem;\n}\n\n.custom-checkbox-button__checkbox--selected {\n    /* For selected checkbox */\n    background-color: #3b82f6;\n}\n```\n\n```html index.html hidden\n<label class=\"custom-checkbox-button\">\n    <input type=\"checkbox\" class=\"custom-checkbox-button__input\" />\n    <div class=\"custom-checkbox-button__square\">\n        <div class=\"custom-checkbox-button__checkbox custom-checkbox-button__checkbox--selected\"></div>\n    </div>\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n</label>\n\n<label class=\"custom-checkbox-button\">\n    <input type=\"checkbox\" class=\"custom-checkbox-button__input\" />\n    <div class=\"custom-checkbox-button__square\">\n        <div class=\"custom-checkbox-button__checkbox custom-checkbox-button__checkbox--selected\"></div>\n    </div>\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n</label>\n\n<label class=\"custom-checkbox-button\">\n    <input type=\"checkbox\" class=\"custom-checkbox-button__input\" />\n    <div class=\"custom-checkbox-button__square\">\n        <div class=\"custom-checkbox-button__checkbox custom-checkbox-button__checkbox--selected\"></div>\n    </div>\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n</label>\n```\n</Playground>\n\n## See also\n\n-   [Box selector](https://phuoc.ng/collection/css-layout/box-selector/)\n-   [Custom radio button](https://phuoc.ng/collection/css-layout/custom-radio-button/)\n"
  },
  {
    "path": "contents/custom-radio-button.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-12-01'\ndescription: Create a custom radio button with CSS flexbox\nkeywords: css flexbox, css radio\nthumbnail: /assets/css-layout/thumbnails/custom-radio-button.png\ntitle: Custom radio button\n---\n\n## HTML\n\n```html index.html\n<label class=\"custom-radio-button\">\n    <!-- The real radio -->\n    <input type=\"radio\" class=\"custom-radio-button__input\" />\n\n    <!-- The fake circle -->\n    <div class=\"custom-radio-button__circle\">\n        <!-- The inner circle -->\n        <div class=\"custom-radio-button__radio custom-radio-button__radio--selected\"></div>\n    </div>\n\n    <!-- The text -->\n    ...\n</label>\n```\n\n## CSS\n\n```css styles.css\n.custom-radio-button {\n    /* Center the content horizontally */\n    align-items: center;\n    display: inline-flex;\n\n    /* Cursor */\n    cursor: pointer;\n}\n\n.custom-radio-button__input {\n    /* Hide it */\n    display: none;\n}\n\n.custom-radio-button__circle {\n    /* Rounded border */\n    border: 1px solid #d1d5db;\n    border-radius: 9999px;\n\n    /* Spacing */\n    margin-right: 0.5rem;\n    padding: 0.25rem;\n}\n\n.custom-radio-button__radio {\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 1rem;\n    width: 1rem;\n\n    /* For not selected radio */\n    background-color: transparent;\n}\n\n.custom-radio-button__radio--selected {\n    /* For selected radio */\n    background-color: #3b82f6;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.custom-radio-button {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Demo */\n    margin: 0.25rem 0;\n    width: 16rem;\n}\n\n.custom-radio-button__input {\n    /* Hide it */\n    display: none;\n}\n\n.custom-radio-button__circle {\n    /* Rounded border */\n    border: 1px solid #d1d5db;\n    border-radius: 9999px;\n\n    /* Spacing */\n    margin-right: 0.5rem;\n    padding: 0.25rem;\n}\n\n.custom-radio-button__radio {\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 1rem;\n    width: 1rem;\n\n    /* For not selected radio */\n    background-color: transparent;\n}\n\n.custom-radio-button__radio--selected {\n    /* For selected radio */\n    background-color: #3b82f6;\n}\n```\n\n```html index.html hidden\n<label class=\"custom-radio-button\">\n    <input type=\"radio\" class=\"custom-radio-button__input\" />\n    <div class=\"custom-radio-button__circle\">\n        <div class=\"custom-radio-button__radio custom-radio-button__radio--selected\"></div>\n    </div>\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n</label>\n\n<label class=\"custom-radio-button\">\n    <input type=\"radio\" class=\"custom-radio-button__input\" />\n    <div class=\"custom-radio-button__circle\">\n        <div class=\"custom-radio-button__radio custom-radio-button__radio--selected\"></div>\n    </div>\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n</label>\n\n<label class=\"custom-radio-button\">\n    <input type=\"radio\" class=\"custom-radio-button__input\" />\n    <div class=\"custom-radio-button__circle\">\n        <div class=\"custom-radio-button__radio custom-radio-button__radio--selected\"></div>\n    </div>\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n</label>\n```\n</Playground>\n\n## See also\n\n-   [Box selector](https://phuoc.ng/collection/css-layout/box-selector/)\n-   [Custom checkbox button](https://phuoc.ng/collection/css-layout/custom-checkbox-button/)\n"
  },
  {
    "path": "contents/diagonal-section.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-25'\ndescription: Create a diagonal section with CSS\nkeywords: css diagonal section, css transform skew\nthumbnail: /assets/css-layout/thumbnails/diagonal-section.png\ntitle: Diagonal section\n---\n\n## HTML\n\n```html index.html\n<div class=\"diagonal-section\">\n    <!-- The diagonal area -->\n    <div class=\"diagonal-section__diagonal\"></div>\n\n    <!-- Content -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.diagonal-section {\n    /* Used to position the diagonal area */\n    position: relative;\n}\n\n.diagonal-section__diagonal {\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Create diagonal sides */\n    transform: skewY(-5deg);\n\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Displayed under the main content */\n    z-index: -1;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.diagonal-section {\n    /* Used to position the diagonal area */\n    position: relative;\n\n    height: 100%;\n    width: 100%;\n}\n\n.diagonal-section__diagonal {\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 50%;\n\n    /* Take full size */\n    height: 2rem;\n    width: 100%;\n\n    /* Create diagonal sides */\n    transform: translate(0, -50%) skewY(-15deg);\n\n    /* Background color */\n    background-color: #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"diagonal-section\">\n    <div class=\"diagonal-section__diagonal\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/docked-at-corner.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-23'\ndescription: Dock an element at corner with CSS\nkeywords: css docked, css flexbox\nthumbnail: /assets/css-layout/thumbnails/docked-at-corner.png\ntitle: Docked at corner\n---\n\n## HTML\n\n```html index.html\n<div class=\"docked-at-corner\">\n    <!-- Docked at the top right corner -->\n    <div class=\"docked-at-corner__docker\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.docked-at-corner {\n    position: relative;\n}\n.docked-at-corner__docker {\n    position: absolute;\n    right: 0;\n    top: 0;\n    transform: translate(50%, -50%);\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    height: 24rem;\n    justify-content: center;\n}\n\n.docked-at-corner {\n    position: relative;\n    height: 16rem;\n    width: 20rem;\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n}\n.docked-at-corner__docker {\n    background-color: #22c55e;\n    border-radius: 9999px;\n\n    position: absolute;\n    right: 0;\n    top: 0;\n    transform: translate(50%, -50%);\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n}\n```\n\n```html index.html hidden\n<div class=\"docked-at-corner\">\n    <div class=\"docked-at-corner__docker\"></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   Discover how to animate a docked element using the [pulse animation](https://phuoc.ng/collection/css-animation/pulse-animation/)\n"
  },
  {
    "path": "contents/dot-leader.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-27'\ndescription: Create dot leaders with CSS flexbox\nkeywords: css dot leader, css flexbox\nthumbnail: /assets/css-layout/thumbnails/dot-leader.png\ntitle: Dot leader\n---\n\n## HTML\n\n```html index.html\n<div class=\"dot-leader\">\n    <!-- Left side -->\n    <div>...</div>\n\n    <!-- Dots -->\n    <div class=\"dot-leader__dots\"></div>\n\n    <!-- Right side -->\n    <div>...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.dot-leader {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.dot-leader__dots {\n    /* Bottom border */\n    border-bottom: 1px dotted #d1d5db;\n\n    /* Take remaining width */\n    flex: 1;\n\n    /* Spacing */\n    margin: 0 0.25rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.dot-leader {\n    width: 16rem;\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    margin: 1rem 0;\n}\n\n.dot-leader__dots {\n    /* Bottom border */\n    border-bottom: 1px dotted #d1d5db;\n\n    /* Take remaining width */\n    flex: 1;\n\n    /* Spacing */\n    margin: 0 0.25rem;\n}\n```\n\n```html index.html hidden\n<div class=\"dot-leader\">\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n    <div class=\"dot-leader__dots\"></div>\n    <div class=\"circle circle--sm\"></div>\n</div>\n\n<div class=\"dot-leader\">\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n    <div class=\"dot-leader__dots\"></div>\n    <div class=\"circle circle--sm\"></div>\n</div>\n\n<div class=\"dot-leader\">\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n    <div class=\"dot-leader__dots\"></div>\n    <div class=\"circle circle--sm\"></div>\n</div>\n\n<div class=\"dot-leader\">\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n    <div class=\"dot-leader__dots\"></div>\n    <div class=\"circle circle--sm\"></div>\n</div>\n\n<div class=\"dot-leader\">\n    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n    <div class=\"dot-leader__dots\"></div>\n    <div class=\"circle circle--sm\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/dot-navigation.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-22'\ndescription: Create dot navigation with CSS flexbox\nkeywords: css dot navigation, css flexbox\nthumbnail: /assets/css-layout/thumbnails/dot-navigation.png\ntitle: Dot navigation\n---\n\n## HTML\n\n```html index.html\n<div class=\"dot-navigation\">\n    <div class=\"dot-navigation__item\"></div>\n\n    <!-- Repeat other dots -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.dot-navigation {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n.dot-navigation__item {\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 0.75rem;\n    width: 0.75rem;\n\n    /* Inactive dot */\n    background-color: transparent;\n    border: 1px solid #d1d5db;\n\n    /* OPTIONAL: Spacing between dots */\n    margin: 0 0.25rem;\n}\n\n/* Active dot */\n.dot-navigation__item--active {\n    background-color: #d1d5db;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.dot-navigation {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n.dot-navigation__item {\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 0.75rem;\n    width: 0.75rem;\n\n    /* Inactive dot */\n    background-color: transparent;\n    border: 1px solid #d1d5db;\n\n    /* OPTIONAL: Spacing between dots */\n    margin: 0 0.25rem;\n}\n\n.dot-navigation__item--active {\n    background-color: #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"dot-navigation\">\n    <div class=\"dot-navigation__item\"></div>\n    <div class=\"dot-navigation__item dot-navigation__item--active\"></div>\n    <div class=\"dot-navigation__item\"></div>\n    <div class=\"dot-navigation__item\"></div>\n    <div class=\"dot-navigation__item\"></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Carousel slider](https://phuoc.ng/collection/css-layout/carousel-slider/)\n"
  },
  {
    "path": "contents/drawer.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-12-13'\ndescription: Create a drawer navigation with CSS\nkeywords: css drawer, css off-canvas\nthumbnail: /assets/css-layout/thumbnails/drawer.png\ntitle: Drawer\n---\n\nThis pattern is also known as off-canvas.\n\n## HTML\n\n```html index.html\n<div class=\"drawer\">\n    <!-- Backdrop -->\n    <div class=\"drawer__overlay\"></div>\n\n    <!-- Sidebar -->\n    <div class=\"drawer__sidebar\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.drawer {\n    /* Take full size */\n    height: 100%;\n    left: 0;\n    position: fixed;\n    top: 0;\n    width: 100%;\n\n    z-index: 9999;\n}\n\n.drawer__overlay {\n    /* Take full size */\n    height: 100%;\n    left: 0;\n    position: fixed;\n    top: 0;\n    width: 100%;\n\n    /* User still can see the content of main page */\n    background-color: rgba(0, 0, 0, 0.5);\n\n    z-index: -1;\n}\n\n.drawer__sidebar {\n    /* Take full height */\n    height: 100%;\n    left: 0;\n    position: fixed;\n    top: 0;\n    width: 200px;\n\n    /* Background */\n    background-color: #fff;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.drawer {\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n\n    display: flex;\n}\n\n.drawer__sidebar {\n    /* Demo */\n    border-right: 1px solid #d1d5db;\n    width: 25%;\n}\n\n.drawer__overlay {\n    /* Demo */\n    background: #4b5563;\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"drawer\">\n    <div class=\"drawer__sidebar\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"drawer__overlay\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/drop-area.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-27'\ndescription: Create a dropping area with CSS flexbox\nkeywords: css dropping area, css flexbox\nthumbnail: /assets/css-layout/thumbnails/drop-area.png\ntitle: Drop area\n---\n\n## HTML\n\n```html index.html\n<div class=\"drop-area\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.drop-area {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Border */\n    border: 0.25rem dashed #d1d5db;\n    border-radius: 0.25rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.drop-area {\n    padding: 0.5rem;\n    height: 100%;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Border */\n    border: 0.25rem dashed #d1d5db;\n    border-radius: 0.25rem;\n}\n```\n\n```html index.html hidden\n<div class=\"drop-area\">\n    <div class=\"lines\">\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n        <div class=\"line line--100\"></div>\n        <div class=\"line line--60\"></div>\n        <div class=\"line line--20\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/drop-cap.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-29'\ndescription: Create a drop cap with CSS\nkeywords: css drop cap, css :first-letter\nthumbnail: /assets/css-layout/thumbnails/drop-cap.png\ntitle: Drop cap\n---\n\n## HTML\n\n```html index.html\n<div class=\"drop-cap\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.drop-cap:first-letter {\n    /* Display at the left */\n    float: left;\n    line-height: 1;\n\n    /* Spacing */\n    margin: 0 0.5rem 0 0;\n    padding: 0 0.5rem;\n\n    /* Optional */\n    border: 2px solid #d1d5db;\n    font-size: 2rem;\n    font-weight: 700;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.drop-cap {\n    overflow: hidden;\n}\n.drop-cap:first-letter {\n    border: 2px solid #d1d5db;\n\n    /* Display at the left */\n    float: left;\n    line-height: 1;\n\n    /* Spacing */\n    margin: 0 0.5rem 0 0;\n    padding: 0 0.5rem;\n\n    /* Optional */\n    font-size: 2rem;\n    font-weight: 700;\n}\n```\n\n```html index.html hidden\n<div class=\"drop-cap\">\n    CSS is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/dropdown.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-29'\ndescription: Create a dropdown with CSS\nkeywords: css dropdown, css menu\nthumbnail: /assets/css-layout/thumbnails/dropdown.png\ntitle: Dropdown\n---\n\n## HTML\n\n```html index.html\n<div class=\"dropdown\">\n    <!-- The trigger element -->\n    <div class=\"dropdown__trigger\">...</div>\n\n    <!-- The content -->\n    <div class=\"dropdown__content\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.dropdown {\n    position: relative;\n}\n\n.dropdown__trigger {\n    cursor: pointer;\n}\n\n/* Hide the dropdown's content by default */\n.dropdown__content {\n    display: none;\n\n    /* Position it right below the trigger element */\n    left: 0;\n    padding-top: 0.25rem;\n    position: absolute;\n    top: 100%;\n\n    /* It should be on the top of other elements */\n    background-color: #fff;\n    z-index: 9999;\n}\n\n/* Show the content when hover on the container */\n.dropdown:hover .dropdown__content {\n    display: block;\n}\n```\n\nYou can use a [triangle button](https://phuoc.ng/collection/css-layout/triangle-buttons/) to indicate that there is content under it.\n\nMove the mouse over the button to see the dropdown.\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 24rem;\n}\n.dropdown {\n    position: relative;\n\n    /* Demo */\n    width: 6rem;\n\n    align-items: flex-start;\n    display: flex;\n    justify-content: center;\n}\n\n.dropdown__trigger {\n    cursor: pointer;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 2rem;\n    width: 6rem;\n    padding: 0.25rem 0.5rem;\n\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n/* Hide the dropdown's content by default */\n.dropdown__content {\n    display: none;\n\n    /* Position it right below the trigger element */\n    left: 0;\n    padding-top: 0.25rem;\n    position: absolute;\n    top: 100%;\n\n    /* It should be on the top of other elements */\n    background-color: #fff;\n    z-index: 9999;\n}\n\n.dropdown__body {\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 6rem;\n    width: 8rem;\n}\n\n/* Show the content when hover on the container */\n.dropdown:hover .dropdown__content {\n    display: block;\n}\n```\n\n```html index.html hidden\n<div class=\"dropdown\">\n    <div class=\"dropdown__trigger\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n        <div class=\"triangle triangle--b triangle--sm\"></div>\n    </div>\n    <div class=\"dropdown__content\">\n        <div class=\"dropdown__body\">\n            <div class=\"lines\">\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--100\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/fading-long-section.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-10'\ndescription: Fading long section to indicate there is more content\nkeywords: css fading overflow, css linear gradient\nthumbnail: /assets/css-layout/thumbnails/fading-long-section.png\ntitle: Fading long section\n---\n\nThe pattern is often used to indicate there is more content.\n\n## HTML\n\n```html index.html\n<div class=\"fading-long-section\">\n    <!-- Main content -->\n    <div class=\"fading-long-section__content\">...</div>\n\n    <!-- The faded element -->\n    <div class=\"fading-long-section__fading\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.fading-long-section {\n    /* Used to position the faded element */\n    position: relative;\n}\n\n.fading-long-section__content {\n    /* Height */\n    height: 100%;\n    overflow-y: hidden;\n}\n\n.fading-long-section__fading {\n    /* Displayed at the bottom */\n    bottom: 0;\n    left: 0;\n    position: absolute;\n\n    /* Size */\n    height: 2rem;\n    width: 100%;\n\n    /* Gradient background */\n    background: linear-gradient(rgba(255, 255, 255, 0.01), #fff);\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    margin: 0.5rem 0;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\n.fading-long-section {\n    /* Used to position the faded element */\n    position: relative;\n\n    height: 24rem;\n}\n\n.fading-long-section__content {\n    /* Height */\n    height: 100%;\n    overflow-y: hidden;\n}\n\n.fading-long-section__fading {\n    /* Displayed at the bottom */\n    bottom: 0;\n    left: 0;\n    position: absolute;\n\n    /* Size */\n    height: 2rem;\n    width: 100%;\n\n    /* Gradient background */\n    background: linear-gradient(rgba(255, 255, 255, 0.01), #fff);\n}\n```\n\n```html index.html hidden\n<div class=\"fading-long-section\">\n    <div class=\"fading-long-section__content\">\n        <div class=\"lines\">\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            <div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div>\n        </div>\n    </div>\n    <div class=\"fading-long-section__fading\"></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Create a reference using React.createRef()](https://phuoc.ng/collection/react-ref/create-a-reference-using-react-create-ref/)\n-   [Customer logos marquee](https://phuoc.ng/collection/css-animation/customer-logos-marquee/)\n"
  },
  {
    "path": "contents/feature-comparison.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-11'\ndescription: Create a feature comparison list with CSS flexbox\nkeywords: css feature comparison, css flexbox\nthumbnail: /assets/css-layout/thumbnails/feature-comparison.png\ntitle: Feature comparison\n---\n\n## HTML\n\n```html index.html\n<div class=\"feature-comparison\">\n    <!-- Feature name -->\n    <div class=\"feature-comparison__feature\">...</div>\n\n    <!-- The model -->\n    <div class=\"feature-comparison__model\">\n        <!--\n        For the first row: display the model name (Basic, Pro, etc.)\n        From the second row: display a yes/no icon indicating the feature is available or not\n        -->\n        ...\n    </div>\n\n    <!-- Repeated other models -->\n    ...\n</div>\n\n<!-- Repeated items -->\n...\n```\n\n## CSS\n\n```css styles.css\n.feature-comparison {\n    align-items: center;\n    display: flex;\n\n    /* Bottom border */\n    border-bottom: 1px solid #d1d5db;\n\n    /* Spacing */\n    padding: 0.25rem 0;\n}\n\n.feature-comparison__feature {\n    /* Take available width */\n    flex: 1;\n}\n\n.feature-comparison__model {\n    /* Center the content */\n    display: flex;\n    justify-content: center;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\n.feature-comparison {\n    align-items: center;\n    display: flex;\n\n    /* Bottom border */\n    border-bottom: 1px solid #d1d5db;\n\n    /* Spacing */\n    padding: 0.25rem 0;\n\n    width: 100%;\n}\n\n.feature-comparison__feature {\n    /* Take available width */\n    flex: 1;\n}\n\n.feature-comparison__model {\n    /* Center the content */\n    display: flex;\n    justify-content: center;\n\n    /* Demo */\n    width: 1.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"feature-comparison\">\n    <div class=\"feature-comparison__feature\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n    <div class=\"feature-comparison__model\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n    <div class=\"feature-comparison__model\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n</div>\n\n<div class=\"feature-comparison\">\n    <div class=\"feature-comparison__feature\">\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"feature-comparison__model\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n    <div class=\"feature-comparison__model\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n</div>\n\n<div class=\"feature-comparison\">\n    <div class=\"feature-comparison__feature\">\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"feature-comparison__model\"></div>\n    <div class=\"feature-comparison__model\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n</div>\n\n<div class=\"feature-comparison\">\n    <div class=\"feature-comparison__feature\">\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"feature-comparison__model\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n    <div class=\"feature-comparison__model\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/feature-list.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-21'\ndescription: Create a feature list with CSS flexbox\nkeywords: css feature list, css flexbox\nthumbnail: /assets/css-layout/thumbnails/feature-list.png\ntitle: Feature list\n---\n\n## HTML\n\n```html index.html\n<!-- Feature item -->\n<div class=\"feature-list\">\n    <!-- Image -->\n    <div class=\"feature-list__image\">...</div>\n\n    <!-- Right side -->\n    <div class=\"feature-list__desc\">...</div>\n</div>\n\n<!-- Repeated items -->\n...\n```\n\n## CSS\n\n```css styles.css\n.feature-list {\n    display: flex;\n\n    /* OPTIONAL: Spacing between items */\n    margin: 0.5rem 0;\n}\n\n/* Reverse the order of image and content */\n.feature-list--reverse {\n    flex-direction: row-reverse;\n}\n\n.feature-list__image {\n    width: 2rem;\n}\n\n.feature-list__desc {\n    /* Take the remaining width */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.feature-list {\n    display: flex;\n\n    /* OPTIONAL: Spacing between items */\n    margin: 0.5rem 0;\n    width: 16rem;\n}\n\n.feature-list--reverse {\n    flex-direction: row-reverse;\n}\n\n.feature-list__image {\n    width: 2rem;\n}\n\n.feature-list__desc {\n    /* Take the remaining width */\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"feature-list\">\n    <div class=\"feature-list__image\">\n        <div class=\"circle circle--md\"></div>\n    </div>\n    <div class=\"feature-list__desc\">\n        <div class=\"lines\">\n    <div class=\"line line--80\"></div>\n    <div class=\"line line--40\"></div>\n    <div class=\"line line--100\"></div>\n    <div class=\"line line--60\"></div>\n    <div class=\"line line--20\"></div>\n</div>\n    </div>\n</div>\n<div class=\"feature-list feature-list--reverse\">\n    <div class=\"feature-list__image\">\n        <div class=\"circle circle--md\"></div>\n    </div>\n    <div class=\"feature-list__desc\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/fixed-at-corner.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-17'\ndescription: Fix an element at corner with CSS\nkeywords: css fixed\nthumbnail: /assets/css-layout/thumbnails/fixed-at-corner.png\ntitle: Fixed at corner\n---\n\n## HTML\n\n```html index.html\n<div class=\"fixed-at-corner\">\n    <!-- Top-left corner -->\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--tl\">...</div>\n\n    <!-- Top-right corner -->\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--tr\">...</div>\n\n    <!-- Bottom-right corner -->\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--br\">...</div>\n\n    <!-- Bottom-left corner -->\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--bl\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.fixed-at-corner {\n    position: relative;\n}\n\n.fixed-at-corner__corner {\n    position: absolute;\n}\n\n.fixed-at-corner__corner--tl {\n    left: 0;\n    top: 0;\n}\n\n.fixed-at-corner__corner--tr {\n    top: 0;\n    right: 0;\n}\n\n.fixed-at-corner__corner--br {\n    bottom: 0;\n    right: 0;\n}\n\n.fixed-at-corner__corner--bl {\n    bottom: 0;\n    left: 0;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.fixed-at-corner {\n    width: 100%;\n    height: 100%;\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    position: relative;\n}\n\n.fixed-at-corner__corner {\n    position: absolute;\n}\n\n.fixed-at-corner__corner--tl {\n    left: 0;\n    top: 0;\n}\n\n.fixed-at-corner__corner--tr {\n    top: 0;\n    right: 0;\n}\n\n.fixed-at-corner__corner--br {\n    bottom: 0;\n    right: 0;\n}\n\n.fixed-at-corner__corner--bl {\n    bottom: 0;\n    left: 0;\n}\n```\n\n```html index.html hidden\n<div class=\"fixed-at-corner\">\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--tl\">\n        <div class=\"triangle triangle--tl triangle--md\"></div>\n    </div>\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--tr\">\n        <div class=\"triangle triangle--tr triangle--md\"></div>\n    </div>\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--br\">\n        <div class=\"triangle triangle--br triangle--md\"></div>\n    </div>\n    <div class=\"fixed-at-corner__corner fixed-at-corner__corner--bl\">\n        <div class=\"triangle triangle--bl triangle--md\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/fixed-at-side.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-21'\ndescription: Fix an element at the middle of side with CSS\nkeywords: css fixed\nthumbnail: /assets/css-layout/thumbnails/fixed-at-side.png\ntitle: Fixed at side\n---\n\n## HTML\n\n```html index.html\n<!-- Fixed at the middle of left side -->\n<div class=\"fixed-at-side fixed-at-side--l\">...</div>\n\n<!-- Fixed at the middle of right side -->\n<div class=\"fixed-at-side fixed-at-side--r\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.fixed-at-side {\n    position: fixed;\n    top: 50%;\n    transform: translate(0px, -50%);\n}\n.fixed-at-side--l {\n    left: 0;\n}\n.fixed-at-side--r {\n    right: 0;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.fixed-at-side {\n    width: 100%;\n    height: 100%;\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    position: relative;\n}\n\n.fixed-at-side__side {\n    height: 40%;\n    position: absolute;\n    top: 50%;\n    transform: translate(0px, -50%);\n}\n.fixed-at-side__side--l {\n    left: 0;\n}\n.fixed-at-side__side--r {\n    right: 0;\n}\n```\n\n```html index.html hidden\n<div class=\"fixed-at-side\">\n    <div class=\"fixed-at-side__side fixed-at-side__side--r\"><div class=\"rectangle rectangle--ver rectangle--md rectangle--100\"></div></div>\n    <div class=\"fixed-at-side__side fixed-at-side__side--l\"><div class=\"rectangle rectangle--ver rectangle--md rectangle--100\"></div></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Carousel slider](https://phuoc.ng/collection/css-layout/carousel-slider/)\n"
  },
  {
    "path": "contents/flipping-number.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-09-07'\ndescription: Create a flipping number in CSS\nkeywords: css flipping number, css flipping clock, css flipping counter\nopenGraphCover: /og/css-layout/flipping-number.png\nthumbnail: /assets/css-layout/thumbnails/flipping-number.png\ntitle: Flipping number\n---\n\nFlipping number layout is a popular display format used in digital clocks, countdown timers, and scoreboards. It uses multiple panels to show each digit of a number, and each panel can flip over to reveal the next number, giving the impression of an analog clock face.\n\nIn web design, flip numbers are a great way to create unique and eye-catching interfaces. They're perfect for displaying all kinds of information, such as scores, prices, or countdowns.\n\nIn this post, we'll learn how to create a flipping number using CSS. Get ready to impress your users with a stunning display!\n\n## Markup\n\nFirst things first, let's prepare the layout for our flipping number. It's a simple layout that involves two elements. The container element creates the top and bottom flipping effects, while the inner element is used to display the number.\n\n```html\n<div class=\"flip\">\n    <div class=\"flip__number\">42</div>\n</div>\n```\n\n## Adding effects\n\nInstead of creating separate elements for the top and bottom backgrounds, we can simplify things by using pseudo-elements. The `::before` element can handle the top background, while the `::after` element can generate the bottom background.\n\nTo make this work, we need to position the pseudo-element absolutely within the container. We can do this by using the `position` property with different values:\n\n```css\n.flip {\n    overflow: hidden;\n}\n.flip::before {\n    content: '';\n    position: absolute;\n}\n```\n\nIt's important to remember that the pseudo-element won't be visible without the `content` property. In our case, the `::before` element doesn't have any content, so we can simply set the `content` property to empty.\n\nNow, let's focus on the `::before` element, which will cover the first half of the container. We can use a combination of `top`, `left`, `height`, and `width` properties to indicate its position and dimensions:\n\n```css\n.flip::before {\n    top: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n}\n```\n\nLastly, let's create a gradient for the top half using the `linear-gradient` function. This will allow us to set the `background` property in the following way:\n\n```css\n.flip::before {\n    background: linear-gradient(to right bottom, rgb(71 85 105), rgb(15 23 42));\n}\n```\n\nIn the code above, we're passing several parameters to the `linear-gradient` function. The first parameter, `to right bottom`, sets the direction of the gradient. In this case, it means the gradient will start at the top left and end at the bottom right.\n\nThe second and third parameters are colors that determine the start and end points of the gradient. The first color, `rgb(71 85 105)`, is a darker shade representing the starting point. The second color, `rgb(15 23 42)`, is an even darker shade representing the ending point.\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css hidden\n.flip {\n    display: inline-flex;\n    padding: 1rem;\n    position: relative;\n\n    border-radius: 0.5rem;\n    overflow: hidden;\n}\n.flip::before {\n    content: '';\n    position: absolute;\n    top: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n    background: linear-gradient(to right bottom, rgb(71 85 105), rgb(15 23 42));\n}\n.flip__number {\n    color: #fff;\n    font-size: 4rem;\n    font-weight: 600;\n    z-index: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"flip\">\n    <div class=\"flip__number\">42</div>\n</div>\n```\n</Playground>\n\nWe can use the same steps for the bottom half, with only one difference: the position and background color. Since the bottom half is positioned at the bottom, it will reset the `bottom` and `left` properties to zero.\n\nHere's how the bottom half can be created using the `::after` pseudo-element.\n\n```css\n.flip::after {\n    content: '';\n    position: absolute;\n    bottom: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n    background: linear-gradient(to right bottom, rgb(100 116 139), rgb(15 23 42));\n}\n```\n\nFinally, to ensure that content is displayed on top of pseudo-elements, we need to set the `z-index` property.\n\n```css\n.flip__number {\n    z-index: 1;\n}\n```\n\nCheck out the result below.\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css hidden\n.flip {\n    display: inline-flex;\n    padding: 1rem;\n    position: relative;\n\n    border-radius: 0.5rem;\n    overflow: hidden;\n}\n.flip::before {\n    content: '';\n    position: absolute;\n    top: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n    background: linear-gradient(to right bottom, rgb(71 85 105), rgb(15 23 42));\n}\n.flip::after {\n    content: '';\n    position: absolute;\n    bottom: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n    background: linear-gradient(to right bottom, rgb(100 116 139), rgb(15 23 42));\n}\n.flip__number {\n    color: #fff;\n    font-size: 4rem;\n    font-weight: 600;\n    z-index: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"flip\">\n    <div class=\"flip__number\">42</div>\n</div>\n```\n</Playground>\n\n## Adding a divider\n\nTo enhance the layout's visual appeal, we can insert a thin divider between the top and bottom halves. We can achieve this by adding a border at the bottom of the first half.\n\n```css\n.flip::before {\n    border-bottom: 1px solid rgb(148 163 184);\n}\n```\n\nAs the border will occupy space, we need to slightly push up the first half to ensure both halves have the same height. We can use a negative value with the `translateY()` function to accomplish this.\n\n```css\n.flip::before {\n    transform: translateY(-1px);\n}\n```\n\nIt's important to note that the value passed must match the border's thickness. Therefore, it's better to use a CSS variable to represent the number. This way, the code will still work even if you increase the border's thickness. Plus, it'll be easier for other engineers on your team to understand, making the code easier to maintain.\n\n```css\n:root {\n    --divider-height: 1px;\n}\n.flip::before {\n    border-bottom: var(--divider-height) solid rgb(148 163 184);\n    transform: translateY(calc(-1 * var(--divider-height)));\n}\n```\n\nLet's take a look at the final result we've achieved so far.\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n:root {\n    --divider-height: 1px;\n}\n.flip {\n    display: inline-flex;\n    padding: 1rem;\n    position: relative;\n\n    border-radius: 0.5rem;\n    overflow: hidden;\n}\n.flip::before {\n    content: '';\n    position: absolute;\n    top: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n    background: linear-gradient(to right bottom, rgb(71 85 105), rgb(15 23 42));\n    border-bottom: var(--divider-height) solid rgb(148 163 184);\n    transform: translateY(calc(-1 * var(--divider-height)));\n}\n.flip::after {\n    content: '';\n    position: absolute;\n    bottom: 0;\n    left: 0;\n    height: 50%;\n    width: 100%;\n    background: linear-gradient(to right bottom, rgb(100 116 139), rgb(15 23 42));\n}\n\n.flip__number {\n    color: #fff;\n    font-size: 4rem;\n    font-weight: 600;\n    z-index: 1;\n}\n```\n\n```html index.html\n<div class=\"flip\">\n    <div class=\"flip__number\">42</div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/floating-label.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-28'\ndescription: Create a floating label with CSS\nkeywords: css floating label, placeholder shown\nthumbnail: /assets/css-layout/thumbnails/floating-label.png\ntitle: Floating label\n---\n\n## HTML\n\n```html index.html\n<div class=\"floating-label\">\n    <!-- The input -->\n    <input placeholder=\"Placeholder\" class=\"floating-label__input\" />\n\n    <!-- The label -->\n    <label class=\"floating-label__label\">Placeholder</label>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.floating-label {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    position: relative;\n}\n\n.floating-label__input {\n    border: none;\n    padding: 0.5rem;\n    height: 100%;\n}\n\n/*\nShow the label at desired position when the\nplaceholder of input isn't shown\n*/\n.floating-label__input:not(:placeholder-shown) + .floating-label__label {\n    background: #fff;\n    transform: translate(0, -200%);\n    opacity: 1;\n}\n\n.floating-label__label {\n    /* Position the label */\n    left: 1rem;\n    position: absolute;\n    top: 100%;\n\n    /* Hide it by default */\n    opacity: 0;\n    transition: all 200ms;\n\n    padding: 0 0.5rem;\n}\n```\n\nType something in the input to see how the label is shown up.\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.floating-label {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    position: relative;\n\n    /* Demo */\n    padding: 0px 1px;\n    height: 2.5rem;\n}\n\n.floating-label__input {\n    border: none;\n    padding: 0.5rem;\n    height: 100%;\n}\n\n/*\nShow the label at desired position when the\nplaceholder of input isn't shown\n*/\n.floating-label__input:not(:placeholder-shown) + .floating-label__label {\n    background: #fff;\n    transform: translate(0, -200%);\n    opacity: 1;\n}\n\n.floating-label__label {\n    /* Position the label */\n    left: 1rem;\n    position: absolute;\n    top: 100%;\n\n    /* Hide it by default */\n    opacity: 0;\n    transition: all 200ms;\n\n    padding: 0 0.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"floating-label\">\n    <input placeholder=\"Placeholder\" class=\"floating-label__input\" />\n    <label class=\"floating-label__label\">Placeholder</label>\n</div>\n```\n</Playground>\n\n## See also\n\n-   Explore some ways to [animate a floating label](https://phuoc.ng/collection/css-animation/floating-label/).\n"
  },
  {
    "path": "contents/folded-corner.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-09-06'\ndescription: Create a folded corner in CSS\nkeywords: css folded corner\nopenGraphCover: /og/css-layout/folded-corner.png\nthumbnail: /assets/css-layout/thumbnails/folded-corner.png\ntitle: Folded corner\n---\n\nThe folded corner layout is a popular design element in web design that adds creativity and uniqueness to a website. It creates the illusion of a folded corner on a webpage, giving it a tangible feel.\n\nUsing this technique can help highlight important information or sections on a page, making it easier for users to navigate a content-heavy website. It can also be used simply for aesthetic purposes, adding an interesting visual element to the page.\n\nIn this post, we will explore various ways to create a folded corner effect. So, get ready to learn some cool techniques!\n\n## Markup\n\nTo begin, let's create the markup for our layout. It's as simple as adding an HTML element.\n\n```html\n<div class=\"box\"></div>\n```\n\n## Using multiple backgrounds\n\nLet's take a moment to imagine an element with a folded corner. This element is made up of two layers: a rectangle with a curved corner and a triangle placed on top of it.\n\nTo create the first layer, we can use the `linear-gradient` function to define the background of the element.\n\n```css\nbackground: linear-gradient(-135deg, transparent 1.7677rem, rgb(226 232 240) 0)\n```\n\nIf you're not familiar with the `linear-gradient` function or the number `1.7677rem` in the sample code, don't worry. Here's what's going on:\n\n-   The `linear-gradient` function creates a gradient background for an element. The `-135deg` specifies the direction of the gradient, which in this case is from the top-right corner to the bottom-left corner.\n-   The first color stop in the gradient is `transparent`, which means there's no color at that point. The second color stop is `rgb(226 232 240)`, which is an RGB color value for that point in the gradient.\n-   The `1.7677rem` and `0` values determine where these colors are positioned within the gradient. `transparent` will be visible for the first `1.7677rem` of the gradient, followed by `rgb(226 232 240)` for the rest.\n\nWondering how we calculated the `1.7677rem` value? It's actually pretty simple. Just imagine that the folded corner is a square with sides of 2.5rem. But because we rotate the first stop by 135 degrees, the side of the square becomes the diagonal.\n\nNow, a square whose diagonal is 2.5rem has a size of `2.5rem / Math.sqrt(2)`, which is `1.7677rem`. Easy, right?\n\nLet's take a look at how it creates a curved corner:\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.box {\n    height: 12rem;\n    width: 16rem;\n\n    background: linear-gradient(-135deg, transparent 1.7677rem, rgb(226 232 240) 0);\n}\n```\n\n```html index.html\n<div class=\"box\"></div>\n```\n</Playground>\n\n### Creating the triangle\n\nThere are several ways to create a triangle, such as using different border colors. However, in this section, we will stick to using the `linear-gradient` function.\n\n```css\n.triangle {\n    background: linear-gradient(to left bottom, transparent 50%, rgb(100 116 139) 0);\n}\n```\n\nIn this example, we use the `to left bottom` value to specify the direction of the gradient. It starts from the top-right corner and goes to the bottom-left corner.\n\nThe first color stop is `transparent`, which means that there is no color at that point. The second color stop is `rgb(100 116 139)`, which specifies an RGB color value for that point in the gradient.\n\nTo create a diagonal line across the box from the top-right to the bottom-left corner, we start with transparency at 50% of this line and then transition into our dark color for the remaining area.\n\nLet's take a look at how it generates a triangle shape:\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.triangle {\n    height: 2.5rem;\n    width: 2.5rem;\n\n    background: linear-gradient(to left bottom, transparent 50%, rgb(100 116 139) 0);\n}\n```\n\n```html index.html\n<div class=\"triangle\"></div>\n```\n</Playground>\n\nNext, let's move the triangle to the top-right corner of the box element. To do this, we can simply adjust the position of the background.\n\n```css\n.box {\n    background: linear-gradient(...) no-repeat 100% 0 / 2.5rem 2.5rem;\n}\n```\n\nLet's break down the declaration into its individual parts:\n\n-   `no-repeat` is a keyword that tells the background image not to repeat.\n-   `100% 0` sets the position of the background image to the top-right corner of the element.\n-   `/ 2.5rem 2.5rem` specifies the size of the background image. The first value represents the width, and the second value represents the height. In this case, both values are set to `2.5rem`, which matches the size of our folded corner square.\n\nCheck out the box element with a triangle attached to the top-right corner. I added a simple dashed border so you can see the bounding of the box.\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.box {\n    height: 12rem;\n    width: 16rem;\n    border: 2px dashed rgb(226 232 240);\n\n    background: linear-gradient(to left bottom, transparent 50%, rgb(100 116 139) 0) no-repeat 100% 0 / 2.5rem 2.5rem;\n}\n```\n\n```html index.html\n<div class=\"box\"></div>\n```\n</Playground>\n\n### Combining backgrounds\n\nNow that you know how to use the linear gradient to create both layers, it's time to merge them and generate the folded corner.\n\nCSS allows us to use multiple declarations for the `background` properties by separating them with commas. Keep in mind that the order of these declarations is important and can affect the final result.\n\n```css\n.box {\n    background:\n        linear-gradient(to left bottom, transparent 50%, rgb(100 116 139) 0) no-repeat 100% 0 / 2.5rem 2.5rem,\n        linear-gradient(-135deg, transparent 1.7677rem, rgb(226 232 240) 0);\n}\n```\n\nWithout further ado, let's take a look at the final result of the steps we've taken so far:\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.box {\n    height: 12rem;\n    width: 16rem;\n\n    background:\n        linear-gradient(to left bottom, transparent 50%, rgb(100 116 139) 0) no-repeat 100% 0 / 2.5rem 2.5rem,\n        linear-gradient(-135deg, transparent 1.7677rem, rgb(226 232 240) 0);\n}\n```\n\n```html index.html\n<div class=\"box\"></div>\n```\n</Playground>\n\n## Using a pseudo-element\n\nIn the previous section, we used a cool approach to generate a folded corner using multiple backgrounds in a single `div` element. However, this approach has some downsides. For example, it's not easy to add more styles to the triangle, like a shadow.\n\nTo add more customization to the triangle, we can use the `:after` pseudo-element to represent it. Here are some basic styles to position the triangle:\n\n```css\n.box {\n     position: relative;\n}\n.box::after {\n    content: '';\n    position: absolute;\n    top: 0;\n    right: 0;\n    width: 2.5rem;\n    height: 2.5rem;\n}\n```\n\nThe `position` property values of `absolute` and `relative` are applied to the box and the triangle, respectively. This ensures that the triangle is positioned absolutely within the box.\n\nAlthough the triangle doesn't contain any information, we still need to set the content property to an empty `''` for it to appear. The `top` and `right` properties position the triangle in the top-right corner, while the `width` and `height` properties determine its size.\n\nWe're using a separate element to represent the triangle. This makes it easy to style it however you want. Want to add a box shadow? No problem!\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.box {\n    height: 12rem;\n    width: 16rem;\n\n    background: linear-gradient(-135deg, transparent 1.7677rem, rgb(226 232 240) 0);\n    position: relative;\n}\n.box::after {\n    content: '';\n    position: absolute;\n    top: 0;\n    right: 0;\n    width: 2.5rem;\n    height: 2.5rem;\n\n    background: linear-gradient(to left bottom, transparent 50%, rgb(100 116 139) 0) no-repeat 100% 0;\n    box-shadow: -0.4rem 0.4rem 0.4rem -0.2rem rgba(0 0 0 / 50);\n}\n```\n\n```html index.html\n<div class=\"box\"></div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/folder-structure.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-03'\ndescription: Create a folder structure with CSS\nkeywords: css folder structure, css folder tree\nthumbnail: /assets/css-layout/thumbnails/folder-structure.png\ntitle: Folder structure\n---\n\n## HTML\n\n```html index.html\n<div class=\"folder-structure\">\n    <ul>\n        <li>\n            <!-- Content -->\n            ...\n\n            <!-- Sub items -->\n            <ul>\n                <li>\n                    <!-- Content -->\n                    ...\n\n                    <!-- Sub items -->\n                    <ul>\n                        <li>...</li>\n                        <li>...</li>\n                        ...\n                    </ul>\n                </li>\n                <li>...</li>\n                ...\n            </ul>\n        </li>\n\n        <!-- Repeat other items -->\n        ...\n    </ul>\n</div>\n```\n\n## CSS\n\n```css styles.css\n:root {\n    --folder-structure-item-height: 0.5rem;\n    --folder-structure-item-margin-left: 2.25rem;\n    --folder-structure-item-padding-top: 0.5rem;\n}\n\n.folder-structure ul {\n    /* Reset */\n    list-style-type: none;\n    margin: 0;\n}\n\n.folder-structure li {\n    padding: var(--folder-structure-item-padding-top) 0rem 0rem 0rem;\n    position: relative;\n}\n\n.folder-structure li::before {\n    border-left: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n    transform: translate(calc(-1 * var(--folder-structure-item-margin-left)), 0);\n\n    /* Size */\n    height: 100%;\n}\n\n.folder-structure li::after {\n    border-bottom: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: calc(var(--folder-structure-item-padding-top) + var(--folder-structure-item-height) / 2);\n    transform: translate(-100%, 0);\n\n    /* Size */\n    width: var(--folder-structure-item-margin-left);\n}\n\n/* Remove the border from the last item */\n.folder-structure li:last-child::before {\n    height: calc(var(--folder-structure-item-padding-top) + var(--folder-structure-item-height) / 2);\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.square {\n    background: #d1d5db;\n    height: var(--square-size);\n    width: var(--square-size);\n}\n.square--sm {\n    --square-size: 0.5rem;\n}\n.square--md {\n    --square-size: 2rem;\n}\n.square--lg {\n    --square-size: 4rem;\n}\n```\n\n```css styles.css hidden\n:root {\n    --folder-structure-item-height: 0.5rem;\n    --folder-structure-item-margin-left: 2.25rem;\n    --folder-structure-item-padding-top: 0.5rem;\n}\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.folder-structure ul {\n    /* Reset */\n    list-style-type: none;\n    margin: 0;\n}\n\n.folder-structure li {\n    padding: var(--folder-structure-item-padding-top) 0rem 0rem 0rem;\n    position: relative;\n}\n\n.folder-structure li::before {\n    border-left: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n    transform: translate(calc(-1 * var(--folder-structure-item-margin-left)), 0);\n\n    /* Size */\n    height: 100%;\n}\n\n.folder-structure li::after {\n    border-bottom: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: calc(var(--folder-structure-item-padding-top) + var(--folder-structure-item-height) / 2);\n    transform: translate(-100%, 0);\n\n    /* Size */\n    width: var(--folder-structure-item-margin-left);\n}\n\n/* Remove the border from the last item */\n.folder-structure li:last-child::before {\n    height: calc(var(--folder-structure-item-padding-top) + var(--folder-structure-item-height) / 2);\n}\n```\n\n```html index.html hidden\n<div class=\"folder-structure\">\n    <ul>\n        <li>\n            <div class=\"square square--sm\"></div>\n            <ul>\n                <li>\n                    <div class=\"square square--sm\"></div>\n                </li>\n            </ul>\n        </li>\n        <li>\n            <div class=\"square square--sm\"></div>\n            <ul>\n                <li>\n                    <div class=\"square square--sm\"></div>\n                    <ul>\n                        <li>\n                            <div class=\"square square--sm\"></div>\n                        </li>\n                    </ul>\n                </li>\n                <li>\n                    <div class=\"square square--sm\"></div>\n                </li>\n            </ul>\n        </li>\n    </ul>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/frame-corners.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-09-06'\ndescription: Create frame corners in CSS\nkeywords: css folded corner\nopenGraphCover: /og/css-layout/frame-corners.png\nthumbnail: /assets/css-layout/thumbnails/frame-corners.png\ntitle: Frame corners\n---\n\nThe frame corner layout pattern is a popular and effective technique in web design. It uses corner elements to frame content on a web page, adding depth and structure. This technique is often used with images and shapes.\n\nIn this post, we'll teach you how to create frame corners with CSS. Are you ready to dive in and learn?\n\n## Markup\n\nThe first step in preparing the layout is to structure it properly. This usually involves two elements: an inner element for displaying the content and an outer element that will display four frames at its corners.\n\nHere's an example of what the layout could look like:\n\n```html\n<div class=\"box\">\n    <div class=\"box__inner\"></div>\n</div>\n```\n\n## Adding overlays\n\nCreating a frame at the corners is a simple idea. We can use CSS to add overlay elements around the content area and position them using absolute positioning.\n\nHere's how to get started: define some CSS variables that can be reused later.\n\n```css\n:root {\n    --frame-border-size: 0.25rem;\n    --frame-height: 1rem;\n    --frame-width: 1rem;\n}\n```\n\nThe `--frame-border-size` variable controls the thickness of the frame, while `--frame-height` and `--frame-width` determine its dimensions. To create a single frame for the outer element, we can use a solid border and adjust the `padding` property to set the space between the border and the box content.\n\n```css\n.box {\n    border: var(--frame-border-size) solid rgb(30 41 59);\n    padding: var(--frame-height) var(--frame-width);\n}\n```\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css hidden\n:root {\n    --frame-border-size: 0.25rem;\n    --frame-height: 1rem;\n    --frame-width: 1rem;\n}\n.box {\n    border: var(--frame-border-size) solid rgb(30 41 59);\n    padding: var(--frame-height) var(--frame-width);\n    height: 12rem;\n    width: 16rem;\n}\n.box__inner {\n    width: 100%;\n    height: 100%;\n    background: rgb(226 232 240);\n}\n```\n\n```html index.html hidden\n<div class=\"box\">\n    <div class=\"box__inner\"></div>\n</div>\n```\n</Playground>\n\nIn order to hide the top and bottom borders of the box, there's a nifty trick we can use called the pseudo-element. Here's how it works:\n\nWe'll use the `::before` pseudo-element to create a vertical overlay that sits outside the box. To achieve this, we position the element absolutely within the box. We set the `position` property to both elements to make sure it stays in place.\n\n```css\n.box {\n    position: relative;\n}\n.box::before {\n    content: '';\n    position: absolute;\n}\n```\n\nTo create the overlay effect, we need to set the `left` and `right` properties to be the same as the frame's width, and the `top` and `bottom` properties to be the same the thickness of the frame border. By using negative numbers for these properties, we push the overlay to the outside of the box, causing the top and bottom borders to overlap.\n\n```css\n.box::before {\n    left: var(--frame-width);\n    right: var(--frame-width);\n\n    top: calc(-1 * var(--frame-border-size));\n    bottom: calc(-1 * var(--frame-border-size));\n}\n```\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css hidden\n:root {\n    --frame-border-size: 0.25rem;\n    --frame-height: 1rem;\n    --frame-width: 1rem;\n}\n.box {\n    border: var(--frame-border-size) solid rgb(30 41 59);\n    padding: var(--frame-height) var(--frame-width);\n    height: 12rem;\n    width: 16rem;\n    position: relative;\n}\n.box::before {\n    content: '';\n    position: absolute;\n    left: var(--frame-width);\n    right: var(--frame-width);\n    top: calc(-1 * var(--frame-border-size));\n    bottom: calc(-1 * var(--frame-border-size));\n    background: rgb(226 232 240);\n}\n```\n\n```html index.html hidden\n<div class=\"box\">\n    <div class=\"box__inner\"></div>\n</div>\n```\n</Playground>\n\nFinally, to create the blank areas at the top and bottom, we make the top and bottom borders the same height as the frame. And voila! The top and bottom borders are hidden, and our box looks sleek and polished.\n\n```css\n.box::before {\n    border-top: var(--frame-height) solid #fff;\n    border-bottom: var(--frame-height) solid #fff;\n}\n```\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css hidden\n:root {\n    --frame-border-size: 0.25rem;\n    --frame-height: 1rem;\n    --frame-width: 1rem;\n}\n.box {\n    border: var(--frame-border-size) solid rgb(30 41 59);\n    padding: var(--frame-height) var(--frame-width);\n    height: 12rem;\n    width: 16rem;\n    position: relative;\n}\n.box::before {\n    content: '';\n    position: absolute;\n    left: var(--frame-width);\n    right: var(--frame-width);\n    top: calc(-1 * var(--frame-border-size));\n    bottom: calc(-1 * var(--frame-border-size));\n    background: rgb(226 232 240);\n    border-top: var(--frame-height) solid #fff;\n    border-bottom: var(--frame-height) solid #fff;\n}\n```\n\n```html index.html hidden\n<div class=\"box\">\n    <div class=\"box__inner\"></div>\n</div>\n```\n</Playground>\n\nWe can use the same approach and create the horizontal overlay element with the `::after` pesudo-element. Now, let's check out the final result of the steps we've followed together so far.\n\n<Playground>\n```css demo.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\n```css styles.css\n:root {\n    --frame-border-size: 0.25rem;\n    --frame-height: 1rem;\n    --frame-width: 1rem;\n}\n.box {\n    border: var(--frame-border-size) solid rgb(30 41 59);\n    padding: var(--frame-height) var(--frame-width);\n    height: 12rem;\n    width: 16rem;\n    position: relative;\n}\n.box__inner {\n    height: 100%;\n    width: 100%;\n    background: rgb(226 232 240);\n}\n.box::before {\n    content: '';\n    position: absolute;\n    left: var(--frame-width);\n    right: var(--frame-width);\n    top: calc(-1 * var(--frame-border-size));\n    bottom: calc(-1 * var(--frame-border-size));\n    border-top: var(--frame-height) solid #fff;\n    border-bottom: var(--frame-height) solid #fff;\n}\n.box::after {\n    content: '';\n    position: absolute;\n    top: var(--frame-height);\n    bottom: var(--frame-height);\n    left: calc(-1 * var(--frame-border-size));\n    right: calc(-1 * var(--frame-border-size));\n    border-left: var(--frame-width) solid #fff;\n    border-right: var(--frame-width) solid #fff;\n}\n```\n\n```html index.html\n<div class=\"box\">\n    <div class=\"box__inner\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/full-background.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-18'\ndescription: Create a full background element with CSS\nkeywords: css background size cover, css full background\nthumbnail: /assets/css-layout/thumbnails/full-background.png\ntitle: Full background\n---\n\n## HTML\n\n```html index.html\n<div class=\"full-background\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.full-background {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n\n    /* Take full size */\n    height: 100vh;\n    width: 100%;\n\n    /* Background */\n    background: url('/path/to/background.jpeg') center center / cover no-repeat;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.full-background {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    background: url('/assets/css-layout/full-background.jpeg') center center / cover no-repeat;\n}\n```\n\n```html index.html hidden\n<div class=\"full-background\">\n    <div class=\"lines\">\n        <div class=\"line line--20\"></div>\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n        <div class=\"line line--60\"></div>\n        <div class=\"line line--20\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/full-screen-menu.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-30'\ndescription: Create a full screen menu with CSS flexbox\nkeywords: css fixed, css flexbox, css menu\nthumbnail: /assets/css-layout/thumbnails/full-screen-menu.png\ntitle: Full screen menu\n---\n\n## HTML\n\n```html index.html\n<div class=\"full-screen-menu\">\n    <!-- The navigation menu -->\n    <ul>\n        ...\n    </ul>\n\n    <!-- The close button -->\n    <button type=\"button\" class=\"full-screen-menu__close\"></button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.full-screen-menu {\n    /* Full screen overlay */\n    height: 100%;\n    left: 0;\n    position: fixed;\n    top: 0;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.full-screen-menu__close {\n    /* Shown at top left corner */\n    left: 1rem;\n    position: absolute;\n    top: 1rem;\n}\n```\n\nYou can use the [close button](https://phuoc.ng/collection/css-layout/close-button/) to create a button for closing the menu.\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.full-screen-menu {\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    position: relative;\n\n    background: #374151;\n}\n\n.full-screen-menu__close {\n    left: 0.5rem;\n    position: absolute;\n    top: 0.5rem;\n\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n}\n\n.full-screen-menu__close::before,\n.full-screen-menu__close::after {\n    content: '';\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.full-screen-menu__close::before {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.full-screen-menu__close::after {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n```html index.html hidden\n<div class=\"full-screen-menu\">\n    <div class=\"lines\">\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n        <div class=\"line line--100\"></div>\n        <div class=\"line line--60\"></div>\n        <div class=\"line line--20\"></div>\n    </div>\n    <button type=\"button\" class=\"full-screen-menu__close\"></button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/grid-lines-background.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-08-30'\ndescription: Create a grid lines background in CSS\nkeywords: grid lines background, linear gradient, radial gradient\nopenGraphCover: /og/css-layout/grid-lines-background.png\nthumbnail: /assets/css-layout/thumbnails/grid-lines-background.png\ntitle: Grid lines background\nupdated: '2023-11-22'\n---\n\nAdding a grid lines background in CSS is an awesome way to give your website some visual interest and structure. This post will show you two simple ways to achieve this.\n\n## Using background image\n\nTo create a grid pattern using CSS, you can use the `background-image` property. Start by creating a square image with two lines – one horizontal and one vertical – that intersect at the center of the square.\n\nThe image can be in either SVG or PNG format. Here's an example of a square image in SVG format:\n\n<Playground>\n```html index.html\n<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'>\n    <rect width='40' height='40' fill='#fff'></rect>\n    <rect x='50%' width='1' height='100%' fill='rgb(203 213 225)'></rect>\n    <rect y='50%' width='100%' height='1' fill='rgb(203 213 225)'></rect>\n</svg>\n```\n</Playground>\n\nThe SVG consists of three rectangles. The first rectangle forms a white square with a size of 40 pixels. The second rectangle is 1 pixel wide and spans the full height to create a vertical line. The `x='50%'` attribute centers the line vertically.\n\nLikewise, the last rectangle is 1 pixel high and spans the full width to create a horizontal line. It's worth noting that the last two rectangles are filled with identical colors.\n\nNext, let's specify the `background-image` property for the element where you want the grid to show up. Simply use the `url()` function to link to your grid image file.\n\n```css\n.grid {\n    background-image: url('/path/to/grid.svg');\n}\n```\n\nIf you want the browser to avoid sending additional request to load the background image, then you can embed it like this:\n\n```css\n.grid {\n    background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Crect width='40' height='40' fill='%23fff' /%3E%3Crect x='50%' width='1' height='100%' fill='rgb(203 213 225)' /%3E%3Crect y='50%' width='100%' height='1' fill='rgb(203 213 225)' /%3E%3C/svg%3E%0A\");\n}\n```\n\nVoila! You now have a grid made up of horizontal and vertical lines that repeat seamlessly.\n\n<Playground>\n```css styles.css\n.grid {\n    height: 16rem;\n    background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Crect width='40' height='40' fill='%23fff' /%3E%3Crect x='50%' width='1' height='100%' fill='rgb(203 213 225)' /%3E%3Crect y='50%' width='100%' height='1' fill='rgb(203 213 225)' /%3E%3C/svg%3E%0A\");\n}\n```\n\n```html index.html\n<div class=\"grid\"></div>\n```\n</Playground>\n\nBy default, an image will repeat both vertically and horizontally, with each repetition being the same size as the background, which is 40 pixels in this case.\n\nBut what if you want to change the size of the repeated image? No problem! You can use the `background-size` property to customize the dimensions. For example, if you set it to 20 pixels, you'll create smaller squares instead. Here's the code you need to make it happen.\n\n```css\n.grid {\n    background-size: 20px;\n}\n```\n\n## Using linear gradients\n\nAnother way to create grid lines in CSS is with the `linear-gradient()` function.\n\nTo make a grid, first, select the element(s) you want to add a grid background to and set the `background-image` property. Then, use the `linear-gradient()` function to specify two colors that are similar or identical, separated by a transparent section of the same width as your desired line thickness.\n\n```css\n.grid {\n    background-image: linear-gradient(to right, gray 1px, transparent 1px);\n}\n```\n\nThe code above creates gray vertical lines that are one pixel thick. You can adjust the line thickness by changing the value of `1px` in both parts of the gradient (i.e., `gray 2px`, `transparent 2px`, for two-pixel-thick lines).\n\nTo make horizontal lines, change `to right` to `to bottom`. If you want both horizontal and vertical lines, simply combine both gradients.\n\n```css\n.grid {\n    background-image:\n        linear-gradient(to right, gray 1px, transparent 1px),\n        linear-gradient(to bottom, gray 1px, transparent 1px);\n}\n```\n\nFinally, don't forget to set the size of the squares using the `background-size` property.\n\nTo adjust the color and spacing of lines, simply change the value of `gray` to any other valid CSS color value, as shown in the example below.\n\n<Playground>\n```css styles.css\n.grid {\n    height: 16rem;\n    background-image:\n        linear-gradient(to right, rgb(203 213 225) 1px, transparent 1px),\n        linear-gradient(to bottom, rgb(203 213 225) 1px, transparent 1px);\n    background-size: 2.5rem 2.5rem;\n    background-position: center center;\n}\n```\n\n```html index.html\n<div class=\"grid\"></div>\n```\n</Playground>\n\n## Grid dot background\n\nWe can use a similar approach to create a grid with a dot background, but this time we'll use the `radial-gradient` function to make circles with a radius of 2 pixels. Don't hesitate to adjust the background color and radius to suit your needs.\n\n<Playground>\n```css styles.css\n.grid {\n    height: 16rem;\n    background-image: radial-gradient(circle, rgb(203 213 225) 2px, #fff 2px);\n    background-size: 2.5rem 2.5rem;\n    background-position: center center;\n}\n```\n\n```html index.html\n<div class=\"grid\"></div>\n```\n</Playground>\n\n## See also\n\n-   [Snap a draggable element to a grid](https://phuoc.ng/collection/react-drag-drop/snap-a-draggable-element-to-a-grid/)\n"
  },
  {
    "path": "contents/grid-without-double-borders.mdx",
    "content": "---\ncategory: Layout\ncreated: '2023-08-27'\ndescription: How to create a CSS grid without double borders\nkeywords: css grid\nopenGraphCover: /og/css-layout/grid-without-double-borders.png\nthumbnail: /assets/css-layout/thumbnails/grid-without-double-borders.png\ntitle: Grid without double borders\n---\n\nCSS grids are an amazing tool for creating complex web page layouts. However, working with default styling can be a bit tricky, especially when it comes to borders. In this post, we'll show you how to create a CSS grid without double borders.\n\nFirst, let's create the grid itself. To do this, we'll use the `display: grid` property.\n\n```css\n.grid {\n    display: grid;\n    grid-template-columns: repeat(3, 1fr);\n    grid-template-rows: repeat(3, 4rem);\n}\n```\n\nIn this example, we've made a 3x3 grid with three columns and three rows. Each row is 4rem tall, and each column takes up an equal fraction of the available space. This means that no matter what size screen you're using, the columns will be evenly spaced.\n\nNow that we've got the grid set up, we want to add borders to each cell. But here's the thing: CSS grids will automatically add double borders to adjacent cells. We'll be exploring some solutions to this issue in the next sections.\n\n## Collapsing the borders\n\nThe grid looks a lot like a table, and as with tables, we face the same issue. But don't worry, there's a solution we can use: the `border-collapse` property. Let me show you an example.\n\n```css\n.grid {\n    border-collapse: collapse;\n}\n\n.grid__item {\n    border: 1px solid rgb(203 213 225);\n}\n```\n\nIn this example, we've set the `border-collapse` property to `collapse`. This should collapse adjacent borders into a single border, and we've also added a 1 pixel border to each cell using the `.grid__item` class. However, the approach doesn't work as expected. Unfortunately, the borders are still duplicated visually, as you can see below.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 16rem;\n}\n```\n\n```css styles.css\n.grid {\n    display: grid;\n    grid-template-columns: repeat(3, 1fr);\n    grid-template-rows: repeat(3, 4rem);\n    border-collapse: collapse;\n    width: 12rem;\n}\n.grid__item {\n    border: 1px solid rgb(203 213 225);\n}\n```\n\n```html index.html\n<div class=\"grid\">\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n</div>\n```\n</Playground>\n\n## Pairing the borders\n\nThere's an easier way to apply borders to your cells. Instead of setting the border for all four sides, we can apply it to just two. This approach is more natural and straightforward.\n\n```css\n:root {\n    --grid-border: 1px solid rgb(203 213 225);\n}\n.grid__item {\n    border-right: var(--grid-border);\n    border-bottom: var(--grid-border);\n}\n```\n\nThe grid will fill in the missing borders at the top and left sides.\n\n```css\n.grid {\n    border-top: var(--grid-border);\n    border-left: var(--grid-border);\n}\n```\n\nAnd there you have it! Check it out, it works just as we expected!\n\n> Did you notice in the sample code above, how I created a CSS variable to define the border? By using the variable in different places, we can avoid duplicating code everywhere. This is what we call **Don't Repeat Yourself** or **DRY**, and it's always a great practice to follow.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 16rem;\n}\n```\n\n```css styles.css\n:root {\n    --grid-border: 1px solid rgb(203 213 225);\n}\n.grid {\n    display: grid;\n    grid-template-columns: repeat(3, 1fr);\n    grid-template-rows: repeat(3, 4rem);\n    border-top: var(--grid-border);\n    border-left: var(--grid-border);\n    width: 12rem;\n}\n.grid__item {\n    border-right: var(--grid-border);\n    border-bottom: var(--grid-border);\n}\n```\n\n```html index.html\n<div class=\"grid\">\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n</div>\n```\n</Playground>\n\n## Using the outline property\n\nAnother solution for styling elements is to use the CSS `outline` property. The outline creates a visual effect similar to a border, but it doesn't take up space on the target element.\n\n```css\n.grid__item {\n    outline: 1px solid rgb(203 213 225);\n}\n```\n\nAlthough it's a step in the right direction, using the `outline` property alone doesn't completely solve the issue of double borders. We're still missing a small piece of the puzzle.\n\nBut don't worry, because CSS grid has a trick up its sleeve. The `grid-gap` property is here to save the day! This handy property creates space between rows and columns in a CSS grid layout. By specifying the size of the gap between each row and column, we gain more control over the spacing of elements within the grid.\n\n```css\n.grid {\n    grid-gap: 1px;\n}\n```\n\nWe can solve the issue by creating a grid with a 1px gap between each row and column, just like the outline. Here's a visual representation of how it works.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 16rem;\n}\n```\n\n```css styles.css\n.grid {\n    display: grid;\n    grid-template-columns: repeat(3, 1fr);\n    grid-template-rows: repeat(3, 4rem);\n    grid-gap: 1px;\n    width: 12rem;\n}\n.grid__item {\n    outline: 1px solid rgb(203 213 225);\n}\n```\n\n```html index.html\n<div class=\"grid\">\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n    <div class=\"grid__item\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/holy-grail.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-16'\ndescription: Create a holy grail layout with CSS flexbox\nkeywords: css flexbox, css holy grail layout, css layout\nthumbnail: /assets/css-layout/thumbnails/holy-grail.png\ntitle: Holy grail\n---\n\n## HTML\n\n```html index.html\n<div class=\"holy-grail\">\n    <header>...</header>\n    <main class=\"holy-grail__main\">\n        <!-- Left sidebar -->\n        <aside class=\"holy-grail__left\">...</aside>\n\n        <!-- Main content -->\n        <article class=\"holy-grail__middle\">...</article>\n\n        <!-- Right sidebar -->\n        <nav class=\"holy-grail__right\">...</nav>\n    </main>\n    <footer>...</footer>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.holy-grail {\n    display: flex;\n    flex-direction: column;\n}\n\n.holy-grail__main {\n    /* Take the remaining height */\n    flex-grow: 1;\n\n    /* Layout the left sidebar, main content and right sidebar */\n    display: flex;\n    flex-direction: row;\n}\n\n.holy-grail__left {\n    width: 25%;\n}\n\n.holy-grail__middle {\n    /* Take the remaining width */\n    flex-grow: 1;\n}\n\n.holy-grail__right {\n    width: 20%;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.holy-grail {\n    display: flex;\n    flex-direction: column;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n}\n\n.holy-grail__header,\n.holy-grail__footer {\n    padding: 0.25rem;\n}\n\n.holy-grail__main {\n    border-top: 1px solid #d1d5db;\n    border-bottom: 1px solid #d1d5db;\n\n    /* Take the remaining height */\n    flex-grow: 1;\n\n    /* Layout the left sidebar, main content and right sidebar */\n    display: flex;\n    flex-direction: row;\n}\n\n.holy-grail__left {\n    width: 25%;\n}\n\n.holy-grail__middle {\n    border-left: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n\n    /* Take the remaining width */\n    flex-grow: 1;\n}\n\n.holy-grail__right {\n    width: 20%;\n}\n```\n\n```html index.html hidden\n<div class=\"holy-grail\">\n    <div class=\"holy-grail__header\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"holy-grail__main\">\n        <div class=\"holy-grail__left\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n        <div class=\"holy-grail__middle\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n        <div class=\"holy-grail__right\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n    </div>\n    <div class=\"holy-grail__footer\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/indeterminate-progress-bar.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2022-10-02'\ndescription: Create an indeterminate progress bar with CSS\nkeywords: css indeterminate progress bar, css progress bar\nthumbnail: /assets/css-layout/thumbnails/indeterminate-progress-bar.png\ntitle: Indeterminate progress bar\n---\n\n## HTML\n\n```html index.html\n<div class=\"indeterminate-progress-bar\">\n    <div class=\"indeterminate-progress-bar__progress\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.indeterminate-progress-bar {\n    /* Color */\n    background-color: #d1d5db;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    height: 0.5rem;\n\n    position: relative;\n    overflow: hidden;\n}\n\n.indeterminate-progress-bar__progress {\n    /* Color */\n    background-color: #3b82f6;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Absolute position */\n    position: absolute;\n    bottom: 0;\n    top: 0;\n    width: 50%;\n\n    /* Move the bar infinitely */\n    animation-duration: 2s;\n    animation-iteration-count: infinite;\n    animation-name: indeterminate-progress-bar;\n}\n\n@keyframes indeterminate-progress-bar {\n    from {\n        left: -50%;\n    }\n    to {\n        left: 100%;\n    }\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.indeterminate-progress-bar {\n    /* Color */\n    background-color: #d1d5db;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    width: 16rem;\n    height: 0.5rem;\n\n    position: relative;\n    overflow: hidden;\n}\n\n.indeterminate-progress-bar__progress {\n    /* Color */\n    background-color: #3b82f6;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    position: absolute;\n    bottom: 0;\n    top: 0;\n    width: 50%;\n\n    animation-duration: 2s;\n    animation-iteration-count: infinite;\n    animation-name: indeterminate-progress-bar;\n}\n\n@keyframes indeterminate-progress-bar {\n    from {\n        left: -50%;\n    }\n    to {\n        left: 100%;\n    }\n}\n```\n\n```html index.html hidden\n<div class=\"indeterminate-progress-bar\">\n    <div class=\"indeterminate-progress-bar__progress\"></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Progress bar](https://phuoc.ng/collection/css-layout/progress-bar/)\n-   [Spinner](https://phuoc.ng/collection/css-layout/spinner/)\n"
  },
  {
    "path": "contents/initial-avatar.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-04'\ndescription: Create an initial avatar with CSS\nkeywords: css avatar\nthumbnail: /assets/css-layout/thumbnails/initial-avatar.png\ntitle: Initial avatar\n---\n\n## HTML\n\n```html index.html\n<div class=\"initial-avatar\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.initial-avatar {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Colors */\n    background-color: #d1d5db;\n    color: #fff;\n\n    /* Rounded border */\n    border-radius: 50%;\n    height: 3rem;\n    width: 3rem;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.initial-avatar {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Colors */\n    background-color: #d1d5db;\n    color: #fff;\n\n    /* Rounded border */\n    border-radius: 50%;\n    height: 3rem;\n    width: 3rem;\n}\n```\n\n```html index.html hidden\n<div class=\"initial-avatar\">\n    PN\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/input-addon.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-16'\ndescription: Create an input add-on with CSS flexbox\nkeywords: css flexbox, css input add-on\nthumbnail: /assets/css-layout/thumbnails/input-addon.png\ntitle: Input addon\n---\n\n## HTML\n\n```html index.html\n<!-- Add-on prepended -->\n<div class=\"input-addon\">\n    <!-- Add-on -->\n    <div class=\"input-addon__addon input-addon__addon--prepended\">...</div>\n\n    <!-- Input -->\n    <input type=\"text\" class=\"input-addon__input\" />\n</div>\n\n<!-- Add-on appended -->\n<div class=\"input-addon\">\n    <!-- Input -->\n    <input type=\"text\" class=\"input-addon__input\" />\n\n    <!-- Add-on -->\n    <div class=\"input-addon__addon input-addon__addon--appended\">...</div>\n</div>\n\n<!-- Appended and prepended add-ons -->\n<div class=\"input-addon\">\n    <!-- Add-on -->\n    <div class=\"input-addon__addon input-addon__addon--prepended\">...</div>\n\n    <!-- Input -->\n    <input type=\"text\" class=\"input-addon__input\" />\n\n    <!-- Add-on -->\n    <div class=\"input-addon__addon input-addon__addon--appended\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.input-addon {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    display: flex;\n}\n\n.input-addon__input {\n    border: none;\n\n    /* Take the remaining width */\n    flex: 1;\n}\n\n.input-addon__addon {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.input-addon__addon--prepended {\n    border-right: 1px solid #d1d5db;\n}\n.input-addon__addon--appended {\n    border-left: 1px solid #d1d5db;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.input-addon {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    display: flex;\n\n    /* Demo */\n    margin-bottom: 0.5rem;\n    width: 16rem;\n}\n\n.input-addon__input {\n    border: none;\n    /* Take the remaining width */\n    flex: 1;\n\n    /* Demo */\n    padding: 0.25rem;\n    margin: 0 0.25rem;\n    width: 5rem;\n}\n\n.input-addon__addon {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Demo */\n    padding: 0.25rem;\n}\n\n.input-addon__addon--prepended {\n    border-right: 1px solid #d1d5db;\n}\n.input-addon__addon--appended {\n    border-left: 1px solid #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"input-addon\">\n    <div class=\"input-addon__addon input-addon__addon--prepended\"><div class=\"circle circle--md\"></div></div>\n    <input type=\"text\" class=\"input-addon__input\" />\n</div>\n\n<div class=\"input-addon\">\n    <input type=\"text\" class=\"input-addon__input\" />\n    <div class=\"input-addon__addon input-addon__addon--appended\"><div class=\"circle circle--md\"></div></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/inverted-corners.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-05-09'\ndescription: Create inverted corners with CSS\nkeywords: css border radius, css inverted border radius, css inverted corners\nthumbnail: /assets/css-layout/thumbnails/inverted-corners.png\ntitle: Inverted corners\n---\n\n## HTML\n\n```html index.html\n<div class=\"inverted-corners\">...</div>\n```\n\n## CSS\n\n```css styles.css\n:root {\n    --inverted-corners-background: #d1d5db;\n    --inverted-corners-size: 2rem;\n}\n\n.inverted-corners {\n    background-color: var(--inverted-corners-background);\n\n    /* Used to position the corner */\n    position: relative;\n}\n\n.inverted-corners::before {\n    content: '';\n\n    /* Absolute position */\n    bottom: calc(-2 * var(--inverted-corners-size));\n    left: 0;\n    position: absolute;\n\n    /* Size */\n    height: calc(2 * var(--inverted-corners-size));\n    width: var(--inverted-corners-size);\n\n    /* Border */\n    background-color: transparent;\n    border-top-left-radius: var(--inverted-corners-size);\n    box-shadow: var(--inverted-corners-background) 0px calc(-1 * var(--inverted-corners-size)) 0px 0px;\n}\n```\n\n<Playground>\n```css styles.css hidden\n:root {\n    --inverted-corners-background: #d1d5db;\n    --inverted-corners-size: 2rem;\n}\n\nbody {\n    height: 24rem;\n}\n\n.inverted-corners {\n    background-color: var(--inverted-corners-background);\n\n    /* Used to position the corner */\n    position: relative;\n\n    /* Demo */\n    height: 2rem;\n    width: 100%;\n}\n\n.inverted-corners::before {\n    content: '';\n\n    /* Absolute position */\n    bottom: calc(-2 * var(--inverted-corners-size));\n    left: 0;\n    position: absolute;\n\n    /* Size */\n    height: calc(2 * var(--inverted-corners-size));\n    width: var(--inverted-corners-size);\n\n    /* Border */\n    background-color: transparent;\n    border-top-left-radius: var(--inverted-corners-size);\n    box-shadow: var(--inverted-corners-background) 0px calc(-1 * var(--inverted-corners-size)) 0px 0px;\n}\n```\n\n```html index.html hidden\n<div class=\"inverted-corners\">\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/keyboard-shortcut.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-16'\ndescription: Create a keyboard shortcut with CSS\nkeywords: kbd tag, keyboard shortcut\nthumbnail: /assets/css-layout/thumbnails/keyboard-shortcut.png\ntitle: Keyboard shortcut\n---\n\nWe use the native `kbd` tag to display the keyboard shortcut.\n\n## HTML\n\n```html index.html\n<kbd class=\"keyboard-shortcut\">...</kbd>\n```\n\n## CSS\n\n```css styles.css\n.keyboard-shortcut {\n    /* Background and color */\n    background-color: rgba(0, 0, 0, 0.1);\n    border-radius: 0.25rem;\n    color: rgba(0, 0, 0, 0.7);\n\n    /* Bottom shadow */\n    box-shadow: #d1d5db 0px -4px 0px inset, rgba(0, 0, 0, 0.4) 0px 1px 1px;\n\n    /* Spacing */\n    padding: 0.25rem 0.5rem;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.keyboard-shortcut {\n    /* Background and color */\n    background-color: rgba(0, 0, 0, 0.1);\n    border-radius: 0.25rem;\n    color: rgba(0, 0, 0, 0.7);\n\n    /* Bottom shadow */\n    box-shadow: #d1d5db 0px -4px 0px inset, rgba(0, 0, 0, 0.4) 0px 1px 1px;\n\n    /* Spacing */\n    padding: 0.25rem 0.5rem;\n}\n```\n\n```html index.html hidden\n<kbd class=\"keyboard-shortcut\">⌘ + C</kbd>\n```\n</Playground>\n"
  },
  {
    "path": "contents/layered-card.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-04'\ndescription: Create a layered card with CSS\nkeywords: css layered card\nthumbnail: /assets/css-layout/thumbnails/layered-card.png\ntitle: Layered card\n---\n\n## HTML\n\n```html index.html\n<div class=\"layered-card\">\n    <div class=\"layered-card__content\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.layered-card {\n    position: relative;\n\n    /* Demo */\n    height: 6rem;\n    width: 6rem;\n}\n\n.layered-card::before {\n    background: #d1d5db;\n    content: '';\n\n    /* Position */\n    top: 0;\n    left: 0;\n    position: absolute;\n    transform: translate(1rem, 1rem);\n\n    /* Size */\n    height: 100%;\n    width: 100%;\n\n    /* Display under the main content */\n    z-index: 0;\n}\n\n.layered-card__content {\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n\n    /* Size */\n    height: 100%;\n    width: 100%;\n\n    z-index: 1;\n\n    background: #fff;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.layered-card {\n    position: relative;\n\n    /* Demo */\n    height: 6rem;\n    width: 6rem;\n}\n\n.layered-card::before {\n    background: #d1d5db;\n    content: '';\n\n    /* Position */\n    top: 0;\n    left: 0;\n    position: absolute;\n    transform: translate(1rem, 1rem);\n\n    /* Size */\n    height: 100%;\n    width: 100%;\n\n    /* Display under the main content */\n    z-index: 0;\n}\n\n.layered-card__content {\n    left: 0;\n    position: absolute;\n    top: 0;\n\n    /* Size */\n    height: 100%;\n    width: 100%;\n    z-index: 1;\n\n    border: 1px solid #d1d5db;\n    background: #fff;\n}\n```\n\n```html index.html hidden\n<div class=\"layered-card\">\n    <div class=\"layered-card__content\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/linear-gauge.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2023-11-20'\ndescription: Create a linear gauge\nopenGraphCover: /og/css-layout/linear-gauge.png\nthumbnail: /assets/css-layout/thumbnails/linear-gauge.png\ntitle: Linear gauge\n---\n\nA **linear gauge** is a handy tool for displaying numerical values within a specific range. It's like a bar with markings that represent the range of values and an indicator that points to the current value. Linear gauges are great for showing progress, performance, or other quantitative metrics quickly and easily. You can use them in dashboards, reports, or presentations to help people understand complex data at a glance. They're simple and intuitive, making them an effective way to communicate important information in a clear and concise manner.\n\nFor instance, think of a fitness app that tracks your daily step count. The app could display a linear gauge that shows your progress towards your daily goal, with markings indicating the range of steps from 0 to the goal amount. As you walk throughout the day, the indicator on the gauge would move in real-time to show how many steps you've taken so far. This visualization can motivate users to reach their step goal and monitor their progress over time. Linear gauges can also be used in other contexts, such as fundraising campaigns or sales targets, to track progress towards specific goals and keep stakeholders informed.\n\nLinear gauges are also used in real-life situations, like in modern cars with fuel economy gauges. These gauges display how efficiently the vehicle is using fuel, with markings indicating different levels of fuel efficiency. The indicator moves up or down based on how efficiently the car is being driven at any given moment, providing drivers with real-time feedback on their driving habits.\n\nThese are just a few examples of how linear gauges can be used to communicate important information quickly and effectively. In this post, we'll learn how to create a linear gauge.\n\n## Setting up the layout\n\nSetting up a layout for a simple linear gauge can be done with just one element that represents the progress.\n\n```html\n<div class=\"gauge\">\n    <div class=\"gauge__progress\"></div>\n</div>\n```\n\nIn order to position the progress indicator inside the gauge, we need to use absolute positioning. First, we set the `position` property of the gauge container to `relative`, so that any child elements with absolute positioning are positioned relative to it.\n\nNext, we set the position property of the progress indicator to `absolute`, and give it a `top` and `left` value of 0. This will position it at the top left corner of the gauge container. Finally, we set the `width` of the progress indicator to a percentage value based on the current value being displayed. This will cause it to stretch or shrink horizontally as needed.\n\n```css\n.gauge {\n    position: relative;\n}\n\n.gauge__progress {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 60%;\n    height: 100%;\n}\n```\n\nSetting different background colors for the gauge and progress indicator can make it easier to distinguish between the two elements, improving the gauge's readability. By using contrasting colors, we can highlight the progress indicator and make it stand out against the gauge's background. This is especially helpful when displaying data with a wide range of values or when there are multiple gauges on a single page. Moreover, choosing visually appealing colors can enhance the gauge's overall look and feel, making it more engaging for viewers to interact with.\n\n```css\n.gauge {\n    background: rgb(203 213 225);\n}\n.gauge__progress {\n    background: rgb(99 102 241);\n}\n```\n\nHere's what the gauge looks like:\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.gauge {\n    position: relative;\n    width: 16rem;\n    height: 0.5rem;\n    background: rgb(203 213 225);\n}\n.gauge__progress {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 60%;\n    height: 100%;\n    background: rgb(99 102 241);\n}\n```\n\n```html index.html\n<div class=\"gauge\">\n    <div class=\"gauge__progress\"></div>\n</div>\n```\n</Playground>\n\n## Adding ticks to the linear gauge\n\nTo make your linear gauge more informative, it's important to include ticks. Ticks provide visual markers that indicate specific points on the gauge and help users understand where they are on the scale.\n\nIn this example, we add five ticks between 0 and 100 percent, representing key milestones along the way. This makes it easier for users to quickly gauge their progress and understand their current position.\n\n```html\n<div class=\"gauge\">\n    <div class=\"gauge__tick\" style=\"left: 0%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 25%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 50%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 75%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 100%;\"></div>\n</div>\n```\n\nTo add ticks to a gauge, we use absolute positioning and set the `left` property to a percentage value based on where we want the tick to appear. For example, to add a tick at the 25% mark, we set `left` to 25%. The tick is then positioned at that point on the gauge.\n\nWe can adjust the height of each tick using the `height` property and set the `width` to 1px to create a thin vertical line. By default, the tick color matches the gauge container, but we can customize it with CSS to create a more visually appealing and informative gauge.\n\nBy adding ticks to a gauge, we can provide viewers with additional information about the data being displayed. We can also use different colors or styles for each tick to make the gauge easier to read and interpret.\n\n```css\n.gauge__tick {\n    position: absolute;\n    top: 100%;\n    height: 0.5rem;\n    width: 1px;\n    background: rgb(203 213 225);\n}\n```\n\nWe can make our gauge even more informative by adding smaller ticks, also known as minor ticks, to the axis. We can insert three minor ticks between each major tick by placing them at a percentage value that falls between two adjacent major ticks. This provides more detailed information on the range of values displayed and helps viewers understand the gauge better.\n\n```html\n<div class=\"gauge\">\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 5%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 10%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 15%;\"></div>\n    ...\n</div>\n```\n\nTo make it easier for viewers to distinguish between major and minor ticks, we can use a separate CSS class and adjust its height to make it smaller than the main ticks. This way, viewers can understand the ticks correctly and avoid any confusion.\n\n```css\n.gauge__tick--minor {\n    height: 0.25rem;\n}\n```\n\nCheck out the demo below to see how even small changes can make a big difference with ticks.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.gauge {\n    position: relative;\n    width: 16rem;\n    height: 0.5rem;\n    background: rgb(203 213 225);\n}\n.gauge__progress {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 60%;\n    height: 100%;\n    background: rgb(99 102 241);\n}\n.gauge__tick {\n    position: absolute;\n    top: 100%;\n    height: 0.5rem;\n    width: 1px;\n    background: rgb(203 213 225);\n}\n.gauge__tick--minor {\n    height: 0.25rem;\n}\n```\n\n```html index.html\n<div class=\"gauge\">\n    <div class=\"gauge__progress\"></div>\n    <div class=\"gauge__tick\" style=\"left: 0%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 5%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 10%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 15%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 20%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 25%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 30%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 35%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 40%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 45%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 50%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 55%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 60%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 65%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 70%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 75%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 80%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 85%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 90%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 95%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 100%;\"></div>\n</div>\n```\n</Playground>\n\n## Enhancing the linear gauge with labels\n\nWe can make the linear gauge even more informative by adding labels to indicate specific values along the gauge. Labels can be used to show the current value of the progress indicator or to mark important milestones on the gauge.\n\nTo add a label, we simply create a new element inside the tick element, give it a class name, and set its content to the value we want to display. With this simple addition, our linear gauge becomes even more useful and visually appealing.\n\n```html\n<div class=\"gauge\">\n    <div class=\"gauge__tick\" style=\"left: 50%;\">\n        <div class=\"gauge__label\">50</div>\n    </div>\n    ...\n</div>\n```\n\nIn this example, we've added a label to the gauge at the 50% mark. To position the label, we use absolute positioning and set its `left` property to 50%. This centers the label horizontally within the tick element. To center the label vertically, we use the `transform` property to move it up by a quarter of the tick's height. By combining these CSS properties, we can create labels that show data in real-time and give viewers more information about the values being displayed. We can also use different colors or styles for each label to make the gauge more visually appealing and easy to read.\n\n```css\n.gauge__label {\n    position: absolute;\n    left: 50%;\n    transform: translate(-50%, 0.25rem);\n}\n```\n\nCustomizing the appearance of our labels can help make them more visually appealing for viewers. By adjusting properties like font size and color, we can create a polished and professional look for our linear gauge.\n\nBy combining ticks, labels, and other design elements, we can create a visualization that effectively communicates important information to viewers in an engaging and informative way.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.gauge {\n    position: relative;\n    width: 16rem;\n    height: 0.5rem;\n    background: rgb(203 213 225);\n}\n.gauge__progress {\n    position: absolute;\n    top: 0;\n    left: 0;\n    width: 60%;\n    height: 100%;\n    background: rgb(99 102 241);\n}\n.gauge__tick {\n    position: absolute;\n    top: 100%;\n    height: 0.5rem;\n    width: 1px;\n    background: rgb(203 213 225);\n}\n.gauge__tick--minor {\n    height: 0.25rem;\n}\n.gauge__label {\n    position: absolute;\n    left: 50%;\n    transform: translate(-50%, 0.5rem);\n}\n```\n\n```html index.html\n<div class=\"gauge\">\n    <div class=\"gauge__progress\"></div>\n    <div class=\"gauge__tick\" style=\"left: 0%;\">\n        <div class=\"gauge__label\">0</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 5%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 10%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 15%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 20%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 25%;\">\n        <div class=\"gauge__label\">25</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 30%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 35%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 40%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 45%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 50%;\">\n        <div class=\"gauge__label\">50</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 55%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 60%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 65%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 70%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 75%;\">\n        <div class=\"gauge__label\">75</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 80%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 85%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 90%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"left: 95%;\"></div>\n    <div class=\"gauge__tick\" style=\"left: 100%;\">\n        <div class=\"gauge__label\">100</div>\n    </div>\n</div>\n```\n</Playground>\n\nBy changing the position from `left` to `top`, we can easily create a horizontal gauge as follows:\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.gauge {\n    position: relative;\n    height: 16rem;\n    width: 0.5rem;\n    background: rgb(203 213 225);\n}\n.gauge__progress {\n    position: absolute;\n    top: 0;\n    left: 0;\n    height: 60%;\n    width: 100%;\n    background: rgb(99 102 241);\n}\n.gauge__tick {\n    position: absolute;\n    left: 100%;\n    width: 0.5rem;\n    height: 1px;\n    background: rgb(203 213 225);\n}\n.gauge__tick--minor {\n    width: 0.25rem;\n}\n.gauge__label {\n    position: absolute;\n    left: 50%;\n    transform: translate(0.5rem, -50%);\n}\n```\n\n```html index.html\n<div class=\"gauge\">\n    <div class=\"gauge__progress\"></div>\n    <div class=\"gauge__tick\" style=\"top: 0%;\">\n        <div class=\"gauge__label\">0</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 5%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 10%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 15%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 20%;\"></div>\n    <div class=\"gauge__tick\" style=\"top: 25%;\">\n        <div class=\"gauge__label\">25</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 30%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 35%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 40%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 45%;\"></div>\n    <div class=\"gauge__tick\" style=\"top: 50%;\">\n        <div class=\"gauge__label\">50</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 55%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 60%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 65%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 70%;\"></div>\n    <div class=\"gauge__tick\" style=\"top: 75%;\">\n        <div class=\"gauge__label\">75</div>\n    </div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 80%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 85%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 90%;\"></div>\n    <div class=\"gauge__tick gauge__tick--minor\" style=\"top: 95%;\"></div>\n    <div class=\"gauge__tick\" style=\"top: 100%;\">\n        <div class=\"gauge__label\">100</div>\n    </div>\n</div>\n```\n</Playground>\n\n## Conclusion\n\nCSS and HTML give us the power to create linear gauges that are not only informative but also visually appealing. By adding ticks and labels to our gauge, we can provide more context for viewers to easily interpret the data in real-time. Customizing the colors and styles of our gauge elements can create a more engaging user experience that encourages viewers to interact with the data. Overall, CSS and HTML offer a robust toolkit for creating effective linear gauges that communicate important information clearly and concisely.\n"
  },
  {
    "path": "contents/lined-paper.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-17'\ndescription: Create lined paper with CSS\nkeywords: css linear gradient, css lined paper, css multiple horizontal lines\nthumbnail: /assets/css-layout/thumbnails/lined-paper.png\ntitle: Lined paper\n---\n\n## HTML\n\n```html index.html\n<div class=\"lined-paper\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.lined-paper {\n    /* Lined background */\n    background-image: linear-gradient(#d1d5db 1px, transparent 0px);\n    background-size: 100% 2em;\n\n    /*\n    Display the content on top of the lines.\n    The line height must be the same as the background size defined above\n    */\n    background-position-y: 1.5rem;\n    line-height: 2em;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.lined-paper {\n    /* Lined background */\n    background-image: linear-gradient(#d1d5db 1px, transparent 0px);\n    background-size: 100% 2em;\n\n    /*\n    Display the content on top of the lines.\n    The line height must be the same as the background size defined above\n    */\n    background-position-y: 1.5rem;\n    line-height: 2em;\n\n    /* Demo */\n    overflow: hidden;\n}\n```\n\n```html index.html hidden\n<div class=\"lined-paper\">\n    Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/masonry-grid.mdx",
    "content": "---\ncategory: Layout\ncreated: '2021-04-28'\ndescription: Create a masonry grid with CSS\nkeywords: css column-count, css column-gap, css masonry, css masonry grid\nthumbnail: /assets/css-layout/thumbnails/masonry-grid.png\ntitle: Masonry grid\n---\n\n## HTML\n\n```html index.html\n<div class=\"masonry-grid\">\n    <!--Item -->\n    <div class=\"masonry-grid__item\">...</div>\n\n    <!-- Repeat other items -->\n</div>\n```\n\n## CSS\n\n```css styles.css\n.masonry-grid {\n    /* It is split into 3 columns */\n    column-count: 3;\n\n    /* The space between columns */\n    column-gap: 1rem;\n}\n\n.masonry-grid__item {\n    /* Prevent a column from breaking into multiple columns */\n    break-inside: avoid;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.masonry-grid {\n    /* It is split into 3 columns */\n    column-count: 3;\n\n    /* The space between columns */\n    column-gap: 1rem;\n\n    /* Demo */\n    height: 100%;\n    width: 100%;\n}\n\n.masonry-grid__item {\n    /* Prevent a column from breaking into multiple columns */\n    break-inside: avoid;\n\n    /* Misc */\n    margin-bottom: 1rem;\n}\n```\n\n```html index.html hidden\n<div class=\"masonry-grid\">\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"masonry-grid__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/media-object.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-16'\ndescription: Create a media object with CSS flexbox\nkeywords: css flexbox, media object\nthumbnail: /assets/css-layout/thumbnails/media-object.png\ntitle: Media object\n---\n\n## HTML\n\n```html index.html\n<div class=\"media-object\">\n    <!-- Media object -->\n    <div class=\"media-object__media\">...</div>\n    <!-- Main content -->\n    <div class=\"media-object__content\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.media-object {\n    /* Align sub-items to top */\n    align-items: start;\n    display: flex;\n}\n\n.media-object__media {\n    margin-right: 0.5rem;\n}\n\n.media-object__content {\n    /* Take the remaining width */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.square {\n    background: #d1d5db;\n    height: var(--square-size);\n    width: var(--square-size);\n}\n.square--sm {\n    --square-size: 0.5rem;\n}\n.square--md {\n    --square-size: 2rem;\n}\n.square--lg {\n    --square-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.media-object {\n    /* Align sub-items to top */\n    align-items: start;\n    display: flex;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.media-object__media {\n    margin-right: 0.5rem;\n}\n\n.media-object__content {\n    /* Take the remaining width */\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"media-object\">\n    <div class=\"media-object__media\">\n        <div class=\"square square--md\"></div>\n    </div>\n    <div class=\"media-object__content\">\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/mega-menu.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-12-29'\ndescription: Create a mega menu with CSS\nkeywords: css mega menu\nthumbnail: /assets/css-layout/thumbnails/mega-menu.png\ntitle: Mega menu\n---\n\n## HTML\n\n```html index.html\n<div class=\"mega-menu\">\n    <!-- Item -->\n    <div class=\"mega-menu__item\">...</div>\n\n    <!-- An item that triggers displaying the mega menu -->\n    <div class=\"mega-menu__item mega-menu__trigger\">\n        <!-- The trigger item's content -->\n        <div>...</div>\n\n        <!-- Mega menu -->\n        <div class=\"mega-menu__content\">...</div>\n    </div>\n\n    <!-- Item -->\n    <div class=\"mega-menu__item\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.mega-menu {\n    /* Used to position the mega menu */\n    position: relative;\n}\n\n.mega-menu__trigger:hover .mega-menu__content {\n    /* Show the mega menu when hovering the trigger item */\n    display: block;\n}\n\n.mega-menu__content {\n    /* Border */\n    border: 1px solid #d1d5db;\n    margin-top: -1px;\n\n    /* Hidden by default */\n    display: none;\n\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 100%;\n\n    /* Take full width */\n    width: 100%;\n\n    /* Displayed on top of other elements */\n    background: #fff;\n    z-index: 9999;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\n.mega-menu {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    position: relative;\n\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Demo */\n    width: 100%;\n}\n\n.mega-menu__item {\n    display: flex;\n    align-items: center;\n\n    height: 100%;\n    flex: 1;\n\n    padding: 0.25rem 0.5rem;\n}\n.mega-menu__item:not(:last-child) {\n    border-right: 1px solid #d1d5db;\n}\n\n.mega-menu__trigger {\n    cursor: pointer;\n\n    /* Demo */\n    height: 2rem;\n\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.mega-menu__content {\n    /* Border */\n    border: 1px solid #d1d5db;\n    /* margin-top: -1px; */\n\n    /* Hidden by default */\n    display: none;\n\n    /* Position it right below the trigger element */\n    left: 0;\n    padding-top: 0.25rem;\n    position: absolute;\n    top: 100%;\n\n    /* Take full width */\n    width: 100%;\n\n    /* It should be on the top of other elements */\n    background-color: #fff;\n    z-index: 9999;\n}\n\n/* Show the mega menu when hovering the trigger item */\n.mega-menu__trigger:hover .mega-menu__content {\n    display: block;\n}\n```\n\n```html index.html hidden\n<div class=\"mega-menu\">\n    <div class=\"mega-menu__item\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n    <div class=\"mega-menu__item mega-menu__trigger\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n        <div class=\"triangle triangle--b triangle--sm\"></div>\n        <div class=\"mega-menu__content\">\n            <div class=\"mega-menu__body\">\n                <div class=\"lines\">\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--100\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </div>\n        </div>\n    </div>\n    <div class=\"mega-menu__item\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/menu.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-17'\ndescription: Create a menu with CSS flexbox\nkeywords: css flexbox, css menu\nthumbnail: /assets/css-layout/thumbnails/menu.png\ntitle: Menu\n---\n\n## HTML\n\n```html index.html\n<div class=\"menu\">\n    <!-- Normal menu item -->\n    <div class=\"menu__item\">...</div>\n\n    <!-- With hot key -->\n    <div class=\"menu__item\">\n        <!-- Label -->\n        ...\n        <!-- Hot key -->\n        <div class=\"menu__hotkey\">...</div>\n    </div>\n\n    <!-- With image and hot key -->\n    <div class=\"menu__item\">\n        <!-- Image -->\n        ...\n\n        <!-- Label -->\n        ...\n\n        <!-- Hot key -->\n        <div class=\"menu__hotkey\">...</div>\n    </div>\n\n    <!-- Divider -->\n    <div class=\"menu__divider\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.menu {\n    display: flex;\n    flex-direction: column;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n}\n\n.menu__item {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n}\n\n.menu__hotkey {\n    /* Push the hot key to the right */\n    margin-left: auto;\n}\n\n.menu__divider {\n    border-bottom: 1px solid #d1d5db;\n    height: 1px;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.menu {\n    display: flex;\n    flex-direction: column;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.menu__item {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n\n    height: 2rem;\n    padding: 0.25rem;\n}\n.menu__item:hover {\n    background: #e5e7eb;\n}\n\n.menu__hotkey {\n    /* Push the hot key to the right */\n    margin-left: auto;\n}\n\n.menu__divider {\n    border-bottom: 1px solid #d1d5db;\n    height: 1px;\n}\n```\n\n```html index.html hidden\n<div class=\"menu\">\n    <div class=\"menu__item\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div>\n    </div>\n    <div class=\"menu__item\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div>\n        <div class=\"menu__hotkey\">⌘ C</div>\n    </div>\n    <div class=\"menu__divider\"></div>\n    <div class=\"menu__item\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n        <div class=\"menu__hotkey\">⌘ V</div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/modal.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-11-17'\ndescription: Create a modal with CSS flexbox\nkeywords: css dialog, css flexbox, css modal\nthumbnail: /assets/css-layout/thumbnails/modal.png\ntitle: Modal\n---\n\n## HTML\n\n```html index.html\n<div class=\"modal\">\n    <!-- Header -->\n    <div class=\"modal__header\">\n        <!-- Title -->\n        ...\n        <!-- Close icon sticks to the right -->\n        ...\n    </div>\n\n    <!-- Content -->\n    ...\n\n    <!-- Footer -->\n    <div class=\"modal__footer\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.modal {\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n}\n\n.modal__header {\n    display: flex;\n    justify-content: space-between;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n}\n\n.modal__footer {\n    display: flex;\n    /* Push the buttons to the right */\n    justify-content: flex-end;\n\n    /* Border */\n    border-top: 1px solid #d1d5db;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.modal {\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    display: flex;\n    flex-direction: column;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.modal__header {\n    display: flex;\n    justify-content: space-between;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n\n    padding: 0.25rem 0.5rem;\n}\n\n.modal__body {\n    flex: 1;\n    overflow: auto;\n}\n\n.modal__footer {\n    display: flex;\n    /* Push the buttons to the right */\n    justify-content: flex-end;\n\n    /* Border */\n    border-top: 1px solid #d1d5db;\n\n    padding: 0.25rem 0.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"modal\">\n    <div class=\"modal__header\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n    <div class=\"modal__body\">\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"modal__footer\">\n        <div class=\"rectangle rectangle--hor rectangle--md rectangle--20\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/nested-dropdowns.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2020-01-13'\ndescription: Create nested dropdown menu with CSS\nkeywords: css dropdown menu, css multi-level dropdown menu, css nested dropdown menu\nthumbnail: /assets/css-layout/thumbnails/nested-dropdowns.png\ntitle: Nested dropdowns\n---\n\n## HTML\n\n```html index.html\n<ul class=\"nested-dropdowns\">\n    <li>A</li>\n    <li>\n        <div class=\"nested-dropdowns__item\">\n            B\n            <div class=\"nested-dropdowns__arrow\">...</div>\n        </div>\n        <ul>\n            <li>B.1</li>\n            <li>B.2</li>\n            <li>\n                <div class=\"nested-dropdowns__item\">\n                    B.3\n                    <div class=\"nested-dropdowns__arrow\">...</div>\n                </div>\n                <ul>\n                    <li>B.3.1</li>\n                    <li>B.3.2</li>\n                    <li>B.3.3</li>\n                    <li>B.3.4</li>\n                </ul>\n            </li>\n            <li>B.4</li>\n            <li>B.5</li>\n        </ul>\n    </li>\n    <li>C</li>\n    <li>D</li>\n</ul>\n```\n\n## CSS\n\n```css styles.css\n.nested-dropdowns {\n    /* Border */\n    border: 1px solid #d1d5db;\n    display: flex;\n\n    /* Reset list styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n.nested-dropdowns li {\n    cursor: pointer;\n\n    /* Spacing */\n    padding: 0.25rem;\n\n    /* Used to position the sub nested-dropdowns */\n    position: relative;\n}\n\n/* The sub nested-dropdowns */\n.nested-dropdowns ul {\n    /* Border */\n    border: 1px solid #d1d5db;\n\n    /* Hidden by default */\n    display: none;\n\n    /* Absolute position */\n    left: 0;\n    position: absolute;\n    top: 100%;\n\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n/* The second level sub nested-dropdowns */\n.nested-dropdowns ul ul {\n    left: 100%;\n    position: absolute;\n    top: 0;\n}\n\n/* Change background color of list item when being hovered */\n.nested-dropdowns li:hover {\n    background-color: rgba(0, 0, 0, 0.1);\n}\n\n/* Show the direct sub nested-dropdowns when hovering the list item */\n.nested-dropdowns li:hover > ul {\n    display: block;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 32rem;\n}\n\n.nested-dropdowns {\n    /* Border */\n    border: 1px solid #d1d5db;\n    display: flex;\n\n    /* Reset list styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n.nested-dropdowns li {\n    cursor: pointer;\n\n    /* Spacing */\n    padding: 0.25rem;\n\n    /* Used to position the sub nested-dropdowns */\n    position: relative;\n}\n\n/* The sub nested-dropdowns */\n.nested-dropdowns ul {\n    /* Border */\n    border: 1px solid #d1d5db;\n\n    /* Hidden by default */\n    display: none;\n\n    /* Absolute position */\n    left: 0;\n    position: absolute;\n    top: 100%;\n\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0;\n}\n\n/* The second level sub nested-dropdowns */\n.nested-dropdowns ul ul {\n    left: 100%;\n    position: absolute;\n    top: 0;\n}\n\n/* Change background color of list item when being hovered */\n.nested-dropdowns li:hover {\n    background-color: rgba(0, 0, 0, 0.1);\n}\n\n/* Show the direct sub nested-dropdowns when hovering the list item */\n.nested-dropdowns li:hover > ul {\n    display: block;\n}\n\n/* Demo */\n.nested-dropdowns__item {\n    align-items: center;\n    display: flex;\n}\n.nested-dropdowns__arrow {\n    margin-left: 0.25rem;\n}\n```\n\n```html index.html hidden\n<ul class=\"nested-dropdowns\">\n    <li>A</li>\n    <li>\n        <div class=\"nested-dropdowns__item\">\n            B <div class=\"nested-dropdowns__arrow\">\n                <div class=\"triangle triangle--b triangle--sm\"></div>\n            </div>\n        </div>\n        <ul>\n            <li>B.1</li>\n            <li>B.2</li>\n            <li>\n                <div class=\"nested-dropdowns__item\">\n                    B.3\n                    <div class=\"nested-dropdowns__arrow\">\n                        <div class=\"triangle triangle--r triangle--sm\"></div>\n                    </div>\n                </div>\n                <ul>\n                    <li>B.3.1</li>\n                    <li>B.3.2</li>\n                    <li>B.3.3</li>\n                    <li>B.3.4</li>\n                </ul>\n            </li>\n            <li>B.4</li>\n            <li>B.5</li>\n        </ul>\n    </li>\n    <li>C</li>\n    <li>D</li>\n</ul>\n```\n</Playground>\n"
  },
  {
    "path": "contents/notification.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-11-17'\ndescription: Create a notification with CSS flexbox\nkeywords: css alert, css flexbox, css notification\nthumbnail: /assets/css-layout/thumbnails/notification.png\ntitle: Notification\n---\n\n## HTML\n\n```html index.html\n<div class=\"notification\">\n    <!-- Content -->\n    <div class=\"notification__body\">...</div>\n\n    <!-- Close button -->\n    <button class=\"notification__close\">\n        <div class=\"notification__close-line notification__close-line--first\"></div>\n        <div class=\"notification__close-line notification__close-line--second\"></div>\n    </button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.notification {\n    display: flex;\n}\n.notification__body {\n    flex: 1;\n    margin-right: 0.5rem;\n}\n```\n\nThe [close button](https://phuoc.ng/collection/css-layout/close-button/) represents the button for closing the notification.\n\n```css\n.notification__close {\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    /* Used to position the inner */\n    position: relative;\n}\n\n.notification__close-line {\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.notification__close-line--first {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.notification__close-line--second {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.notification {\n    display: flex;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem;\n    width: 16rem;\n}\n.notification__body {\n    flex: 1;\n    margin-right: 0.5rem;\n}\n\n.notification__close {\n    /* Reset */\n    background-color: transparent;\n    border-color: transparent;\n\n    /* Cursor */\n    cursor: pointer;\n\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    /* Used to position the inner */\n    position: relative;\n}\n\n.notification__close-line {\n    /* Background color */\n    background-color: #d1d5db;\n\n    /* Position */\n    position: absolute;\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.notification__close-line--first {\n    /* Position */\n    left: 0px;\n    top: 50%;\n    transform: translate(0%, -50%) rotate(45deg);\n\n    /* Size */\n    height: 1px;\n    width: 100%;\n}\n\n.notification__close-line--second {\n    /* Position */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, 0%) rotate(45deg);\n\n    /* Size */\n    height: 100%;\n    width: 1px;\n}\n```\n\n```html index.html hidden\n<div class=\"notification\">\n    <div class=\"notification__body\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <button class=\"notification__close\">\n        <div class=\"notification__close-line notification__close-line--first\"></div>\n        <div class=\"notification__close-line notification__close-line--second\"></div>\n    </button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/overlay-play-button.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-30'\ndescription: Create an overlay play button with CSS flexbox\nkeywords: css flexbox\nthumbnail: /assets/css-layout/thumbnails/overlay-play-button.png\ntitle: Overlay play button\n---\n\n## HTML\n\n```html index.html\n<div class=\"overlay-play-button\">\n    <!-- The video element -->\n    <video src=\"...\" />\n\n    <!-- The overlay area -->\n    <div class=\"overlay-play-button__overlay\">\n        <!-- The player button -->\n        <div class=\"overlay-play-button__play\">...</div>\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.overlay-play-button {\n    /* Used to position the overlay */\n    position: relative;\n}\n\n.overlay-play-button__overlay {\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Add a dark background */\n    background-color: rgba(0, 0, 0, 0.25);\n}\n\n.overlay-play-button__play {\n    border: 0.25rem solid #fff;\n    border-radius: 9999px;\n    height: 3rem;\n    width: 3rem;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.overlay-play-button {\n    /* Used to position the overlay */\n    position: relative;\n\n    /* Demo */\n    height: 100%;\n    width: 100%;\n}\n\n.overlay-play-button__overlay {\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Add a dark background */\n    background-color: #4b5563;\n}\n\n.overlay-play-button__play {\n    border: 0.25rem solid #fff;\n    border-radius: 9999px;\n    height: 3rem;\n    width: 3rem;\n\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```html index.html hidden\n<div class=\"overlay-play-button\">\n    <div class=\"overlay-play-button__overlay\">\n        <div class=\"overlay-play-button__play\">\n            <div class=\"triangle triangle--r triangle--sm\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/pagination.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-17'\ndescription: Create a pagination with CSS flexbox\nkeywords: css flexbox, css pagination\nthumbnail: /assets/css-layout/thumbnails/pagination.png\ntitle: Pagination\n---\n\n## HTML\n\n```html index.html\n<div class=\"pagination\">\n    <!-- Pagination item -->\n    <div class=\"pagination__item\">...</div>\n\n    <!-- Repeat other items -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.pagination {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 4px;\n}\n\n.pagination__item {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.pagination__item:not(:last-child) {\n    /* Right border */\n    border-right: 1px solid #d1d5db;\n}\n\n.pagination__item--active {\n    background-color: #d1d5db;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.pagination {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 4px;\n}\n\n.pagination__item {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    padding: 0.25rem 0.5rem;\n}\n\n.pagination__item:not(:last-child) {\n    /* Right border */\n    border-right: 1px solid #d1d5db;\n}\n\n.pagination__item--active {\n    background-color: #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"pagination\">\n    <div class=\"pagination__item\">1</div>\n    <div class=\"pagination__item pagination__item--active\">2</div>\n    <div class=\"pagination__item\">3</div>\n    <div class=\"pagination__item\">4</div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/pie-chart.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2023-11-17'\ndescription: Create a pie chart\nopenGraphCover: /og/css-layout/pie-chart.png\nthumbnail: /assets/css-layout/thumbnails/pie-chart.png\ntitle: Pie chart\n---\n\nPie charts are a great way to visually represent data. They show data as parts of a whole, making it easy to compare and analyze. Pie charts are especially helpful when working with percentages or proportions that add up to 100%. They can also help identify trends, patterns, and outliers in the data. By using different colors and labeling each slice, you can create a clear and easy-to-understand representation of complex information.\n\nIn this post, we'll show you how to create a pie chart using pure HTML and CSS. It's a simple yet effective way to communicate important data points to your audience. Let's get started!\n\n## Setting up the layout\n\nGenerating a pie chart is a simple process. A pie chart is usually placed in a circle. To begin, we divide the circle into two equal halves.\n\n```html\n<div class=\"circle\">\n    <div class=\"circle__half circle__half--1\"></div>\n    <div class=\"circle__half circle__half--2\"></div>\n</div>\n```\n\nTo create the chart, we rotate one half of the circle based on the percentage of progress being displayed, while the other half remains stationary as the chart's background. In the next section, we'll dive into the details of how to implement this idea.\n\n## Positioning halves\n\nTo create a circle shape for our container, we can use the `border-radius` property and set it to 50%. This will round all four corners and voila! We have a perfect circle. Don't forget to specify the `height` and `width` of the circle to determine its size. If both values are the same, our circle will be perfectly round and symmetrical.\n\n```css\n.circle {\n    border-radius: 50%;\n    height: 12rem;\n    width: 12rem;\n}\n```\n\nBoth halves of the circle are positioned absolutely, so we need to change the `position` style to `relative`.\n\n```css\n.circle {\n    position: relative;\n    overflow: hidden;\n}\n```\n\nWhen creating a pie chart inside a circle, it's crucial to use the `overflow: hidden` property. This ensures that any parts of the pie chart that extend beyond the bounds of the circle are hidden from view, giving the chart a professional and polished look.\n\nTo position the two halves of the circle, we use `position: absolute` in CSS. This lets us place the elements anywhere we want within their parent container. Both halves should have a height of 50% and a width of 100%, so they each occupy half of the circle.\n\nTo ensure proper positioning, we also set `transform-origin: 50% 100%;`. This ensures that when we rotate one of the halves, it rotates around its bottom center point, which is exactly what we need to create a pie chart.\n\n```css\n.circle__half {\n    position: absolute;\n    top: 0;\n    height: 50%;\n    width: 100%;\n    transform-origin: 50% 100%;\n}\n```\n\nTo give the first half of the circle a background color, we can apply a CSS style to it. This will make the portion of the chart that represents completed progress have a solid color.\n\n```css\n.circle__half--1 {\n    background: rgb(99 102 241);\n}\n```\n\nBy using positioning properties, we can easily create a pie chart. We rotate one half of the circle based on the percentage of progress being displayed, while the other half remains stationary, acting as the chart's background.\n\nTo illustrate, let's say we want to display progress by rotating the second half of the circle. In the sample code below, we rotate it by 120 degrees:\n\n```css\n.circle__half--2 {\n    transform: rotate(120deg);\n}\n```\n\nTo make the second half of the circle transparent, we need to set its `background` property to `inherit`. This is because we only want the first half of the circle to have a solid color while the second half should be see-through to show the underlying container. By setting `background: inherit`, we tell the browser to use the same background color as its parent element. This creates a smooth transition between our pie chart and its surrounding container.\n\n```css\n.circle__half--2 {\n    background: inherit;\n}\n```\n\nTake a look at the demo below:\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.circle {\n    background: rgb(203 213 225);\n    border-radius: 50%;\n    position: relative;\n    overflow: hidden;\n    height: 12rem;\n    width: 12rem;\n}\n.circle__half {\n    position: absolute;\n    top: 0;\n    height: 50%;\n    width: 100%;\n    transform-origin: 50% 100%;\n}\n.circle__half--1 {\n    background: rgb(99 102 241);\n}\n.circle__half--2 {\n    background: inherit;\n    transform: rotate(120deg);\n}\n```\n\n```html index.html\n<div class=\"circle\">\n    <div class=\"circle__half circle__half--1\"></div>\n    <div class=\"circle__half circle__half--2\"></div>\n</div>\n```\n</Playground>\n\nKeep in mind that if you want to display a pie chart with a degree greater than 180, the second half must have the same background color as the first half.\n\n```css\n.circle__half--2 {\n    background: rgb(99 102 241);\n    transform: rotate(60deg);\n}\n```\n\nHere's an example of how to create a pie chart using 240 degrees.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n```\n\n```css styles.css\n.circle {\n    background: rgb(203 213 225);\n    border-radius: 50%;\n    position: relative;\n    overflow: hidden;\n    height: 12rem;\n    width: 12rem;\n}\n.circle__half {\n    position: absolute;\n    top: 0;\n    height: 50%;\n    width: 100%;\n    transform-origin: 50% 100%;\n}\n.circle__half--1 {\n    background: rgb(99 102 241);\n}\n.circle__half--2 {\n    background: rgb(99 102 241);\n    transform: rotate(60deg);\n}\n```\n\n```html index.html\n<div class=\"circle\">\n    <div class=\"circle__half circle__half--1\"></div>\n    <div class=\"circle__half circle__half--2\"></div>\n</div>\n```\n</Playground>\n\n## Conclusion\n\nPie charts are an excellent way to visually represent data. They help viewers quickly and easily understand how different parts relate to the whole. With pure HTML and CSS, creating a pie chart is simple and customizable.\n\nIn this post, we'll cover the basics of creating a pie chart in CSS. You'll learn how to position the circle halves using absolute positioning and `transform-origin`. We'll also discuss setting background colors for each half and rotating one half based on the progress percentage.\n\nBy using these techniques, you can create beautiful and informative pie charts that will impress your audience. Remember to keep it simple, avoid cluttering your chart with too much information, and label each slice clearly. Use colors sparingly to ensure viewers can easily understand what they're looking at.\n"
  },
  {
    "path": "contents/popover-arrow.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-12-03'\ndescription: Create a popover arrow with CSS\nkeywords: css arrow, css\nthumbnail: /assets/css-layout/thumbnails/popover-arrow.png\ntitle: Popover arrow\n---\n\n## HTML\n\n```html index.html\n<div class=\"popover-arrow\">\n    <!-- The content -->\n    ...\n\n    <!-- Top left arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--tl\"></div>\n\n    <!-- Top center arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--tc\"></div>\n\n    <!-- Top right arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--tr\"></div>\n\n    <!-- Right top arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--rt\"></div>\n\n    <!-- Right center arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--rc\"></div>\n\n    <!-- Right bottom arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--rb\"></div>\n\n    <!-- Bottom left arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--bl\"></div>\n\n    <!-- Bottom center arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--bc\"></div>\n\n    <!-- Bottom right arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--br\"></div>\n\n    <!-- Left top arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--lt\"></div>\n\n    <!-- Left center arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--lc\"></div>\n\n    <!-- Left bottom arrow -->\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--lb\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.popover-arrow {\n    /* Border */\n    border: 1px solid #d1d5db;\n\n    /* Used to position the arrow */\n    position: relative;\n}\n\n.popover-arrow__arrow {\n    /* Size */\n    height: 0.5rem;\n    width: 0.5rem;\n\n    background-color: #fff;\n    position: absolute;\n}\n\n.popover-arrow__arrow--tl {\n    /* Position at the top left corner */\n    left: 1rem;\n    top: 0;\n\n    /* Border */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--tc {\n    /* Position at the top center */\n    left: 50%;\n    top: 0;\n\n    /* Border */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--tr {\n    /* Position at the top right corner */\n    right: 1rem;\n    top: 0;\n\n    /* Border */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--rt {\n    /* Position at the right top corner */\n    right: 0;\n    top: 1rem;\n\n    /* Border */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, 50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--rc {\n    /* Position at the right center */\n    right: 0;\n    top: 50%;\n\n    /* Border */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--rb {\n    /* Position at the right bottom corner */\n    bottom: 1rem;\n    right: 0;\n\n    /* Border */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--bl {\n    /* Position at the bottom left corner */\n    bottom: -0.5rem;\n    left: 1rem;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--bc {\n    /* Position at the bottom center */\n    bottom: -0.5rem;\n    left: 50%;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--br {\n    /* Position at the bottom right corner */\n    bottom: -0.5rem;\n    right: 1rem;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--lt {\n    /* Position at the left top corner */\n    left: 0;\n    top: 1rem;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translate(-50%, 50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--lc {\n    /* Position at the left center */\n    left: 0;\n    top: 50%;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--lb {\n    /* Position at the left bottom corner */\n    bottom: 1rem;\n    left: 0;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    height: 24rem;\n}\n\n.popover-arrow {\n    /* Border */\n    border: 1px solid #d1d5db;\n\n    /* Used to position the arrow */\n    position: relative;\n\n    /* Demo */\n    height: 16rem;\n    width: 16rem;\n}\n\n.popover-arrow__arrow {\n    /* Size */\n    height: 1rem;\n    width: 1rem;\n\n    background-color: #fff;\n    position: absolute;\n}\n\n.popover-arrow__arrow--tl {\n    /* Position at the top left corner */\n    left: 1rem;\n    top: 0;\n\n    /* Border */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--tc {\n    /* Position at the top center */\n    left: 50%;\n    top: 0;\n\n    /* Border */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--tr {\n    /* Position at the top right corner */\n    right: 1rem;\n    top: 0;\n\n    /* Border */\n    border-left: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--rt {\n    /* Position at the right top corner */\n    right: 0;\n    top: 1rem;\n\n    /* Border */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, 50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--rc {\n    /* Position at the right center */\n    right: 0;\n    top: 50%;\n\n    /* Border */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--rb {\n    /* Position at the right bottom corner */\n    bottom: 1rem;\n    right: 0;\n\n    /* Border */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--bl {\n    /* Position at the bottom left corner */\n    bottom: -1rem;\n    left: 1rem;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translate(50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--bc {\n    /* Position at the bottom center */\n    bottom: -1rem;\n    left: 50%;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--br {\n    /* Position at the bottom right corner */\n    bottom: -1rem;\n    right: 1rem;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-right: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--lt {\n    /* Position at the left top corner */\n    left: 0;\n    top: 1rem;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translate(-50%, 50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--lc {\n    /* Position at the left center */\n    left: 0;\n    top: 50%;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n\n.popover-arrow__arrow--lb {\n    /* Position at the left bottom corner */\n    bottom: 1rem;\n    left: 0;\n\n    /* Border */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translate(-50%, -50%) rotate(45deg);\n}\n```\n\n```html index.html hidden\n<div class=\"popover-arrow\">\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--tl\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--tc\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--tr\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--rt\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--rc\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--rb\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--bl\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--bc\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--br\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--lt\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--lc\"></div>\n    <div class=\"popover-arrow__arrow popover-arrow__arrow--lb\"></div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Speech bubble](https://phuoc.ng/collection/css-layout/speech-bubble/)\n-   [Triangle buttons](https://phuoc.ng/collection/css-layout/triangle-buttons/)\n"
  },
  {
    "path": "contents/presence-indicator.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-11-29'\ndescription: Create a presence indicator with CSS\nkeywords: css indicator\nthumbnail: /assets/css-layout/thumbnails/presence-indicator.png\ntitle: Presence indicator\n---\n\n## HTML\n\n```html index.html\n<div class=\"presence-indicator\">\n    <!-- Other element such as avatar -->\n    ...\n\n    <!-- The presence indicator -->\n    <div class=\"presence-indicator__indicator\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.presence-indicator {\n    position: relative;\n}\n\n.presence-indicator__indicator {\n    /* Shown at the bottom right corner */\n    bottom: 0;\n    position: absolute;\n    right: 0;\n    transform: translate(50%, 50%);\n\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 1rem;\n    width: 1rem;\n\n    /* Background color */\n    background-color: #22c55e;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.presence-indicator {\n    position: relative;\n\n    /* Demo */\n    background-color: #d1d5db;\n    border-radius: 9999px;\n    height: 6rem;\n    width: 6rem;\n}\n\n.presence-indicator__indicator {\n    /* Shown at the bottom right corner */\n    bottom: 0;\n    position: absolute;\n    right: 0;\n    transform: translate(50%, 50%);\n\n    /* Rounded border */\n    border-radius: 9999px;\n    height: 1rem;\n    width: 1rem;\n\n    /* Background color */\n    background-color: #22c55e;\n}\n```\n\n```html index.html hidden\n<div class=\"presence-indicator\">\n    <div class=\"presence-indicator__indicator\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/previous-next-buttons.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-17'\ndescription: Create previous and next buttons with CSS flexbox\nkeywords: css flexbox, css pagination\nthumbnail: /assets/css-layout/thumbnails/previous-next-buttons.png\ntitle: Previous next buttons\n---\n\n## HTML\n\n```html index.html\n<div class=\"previous-next-buttons\">\n    <!-- Previous link sticks to the left -->\n    <div class=\"previous-next-buttons__nav\">\n        <a class=\"previous-next-buttons__button previous-next-buttons__button--l\"></a>\n    </div>\n\n    <!-- Next link sticks to the right -->\n    <div class=\"previous-next-buttons__nav\">\n        <a class=\"previous-next-buttons__button previous-next-buttons__button--r\"></a>\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.previous-next-buttons {\n    align-items: center;\n    display: flex;\n    justify-content: space-between;\n}\n```\n\nYou can use the [arrow buttons](https://phuoc.ng/collection/css-layout/arrow-buttons/) to create the previous and next buttons.\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.previous-next-buttons {\n    align-items: center;\n    display: flex;\n    justify-content: space-between;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.previous-next-buttons__nav {\n    position: relative;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem 0.5rem;\n\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    height: 2rem;\n    width: 3rem;\n}\n\n.previous-next-buttons__button {\n    /* Transparent background */\n    background-color: transparent;\n\n    /* Size */\n    height: 0.5rem;\n    width: 0.5rem;\n}\n\n.previous-next-buttons__button--r {\n    /* Edges */\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    transform: translateX(-25%) rotate(45deg);\n}\n\n.previous-next-buttons__button--l {\n    /* Edges */\n    border-bottom: 1px solid #d1d5db;\n    border-left: 1px solid #d1d5db;\n    transform: translateX(25%) rotate(45deg);\n}\n```\n\n```html index.html hidden\n<div class=\"previous-next-buttons\">\n    <div class=\"previous-next-buttons__nav\">\n        <div class=\"previous-next-buttons__button previous-next-buttons__button--l\"></div>\n    </div>\n    <div class=\"previous-next-buttons__nav\">\n        <div class=\"previous-next-buttons__button previous-next-buttons__button--r\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/price-tag.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-03'\ndescription: Create a price tag with CSS\nkeywords: css price tag\nthumbnail: /assets/css-layout/thumbnails/price-tag.png\ntitle: Price tag\n---\n\n## HTML\n\n```html index.html\n<div class=\"price-tag\">...</div>\n```\n\n## CSS\n\n```css styles.css\n:root {\n    --price-tag-background: #d1d5db;\n    --price-tag-height: 2rem;\n}\n\n.price-tag {\n    background: var(--price-tag-background);\n    color: #fff;\n\n    /* Center the price */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Used to position the triangle */\n    position: relative;\n\n    /* Size */\n    height: var(--price-tag-height);\n\n    /* Spacing */\n    padding: 0.25rem 0.5rem;\n}\n\n/* The triangle */\n.price-tag::before {\n    content: '';\n\n    border-color: transparent var(--price-tag-background) transparent transparent;\n    border-style: solid;\n    border-width: calc(var(--price-tag-height) / 2) calc(var(--price-tag-height) / 2) calc(var(--price-tag-height) / 2) 0rem;\n\n    /* Position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n    transform: translate(-100%, 0px);\n}\n\n/* The dot */\n.price-tag::after {\n    content: '';\n\n    /* Make it like a cirle */\n    background: #fff;\n    border-radius: 9999rem;\n\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 50%;\n    transform: translate(-0.5rem, -50%);\n\n    /* Size */\n    height: 0.5rem;\n    width: 0.5rem;\n}\n```\n\n<Playground>\n```css styles.css hidden\n:root {\n    --price-tag-background: #d1d5db;\n    --price-tag-height: 2rem;\n}\n\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.price-tag {\n    background: var(--price-tag-background);\n    color: #fff;\n\n    /* Center the price */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Used to position the triangle */\n    position: relative;\n\n    /* Size */\n    height: var(--price-tag-height);\n\n    /* Spacing */\n    padding: 0.25rem 0.5rem;\n}\n\n/* The triangle */\n.price-tag::before {\n    content: '';\n\n    border-color: transparent var(--price-tag-background) transparent transparent;\n    border-style: solid;\n    border-width: calc(var(--price-tag-height) / 2) calc(var(--price-tag-height) / 2) calc(var(--price-tag-height) / 2)\n        0rem;\n\n    /* Position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n    transform: translate(-100%, 0px);\n}\n\n/* The dot */\n.price-tag::after {\n    content: '';\n\n    /* Make it like a cirle */\n    background: #fff;\n    border-radius: 9999rem;\n\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 50%;\n    transform: translate(-0.5rem, -50%);\n\n    /* Size */\n    height: 0.5rem;\n    width: 0.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"price-tag\">99.99$</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/pricing-table.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-18'\ndescription: Create a pricing table with CSS flexbox\nkeywords: css flexbox, css pricing table\nthumbnail: /assets/css-layout/thumbnails/pricing-table.png\ntitle: Pricing table\n---\n\n## HTML\n\n```html index.html\n<div class=\"pricing-table\">\n    <!-- Pricing column -->\n    <div class=\"pricing-table__column\">\n        <!-- Title -->\n        ...\n\n        <!-- Price -->\n        ...\n\n        <!-- Description -->\n        ...\n\n        <!-- Button -->\n        ...\n    </div>\n\n    <!-- Repeated pricing columns -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.pricing-table {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.pricing-table__column {\n    /* Content is centered vertically */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n\n    /* Make all columns have the same width */\n    flex: 1;\n\n    /* OPTIONAL: Space between columns */\n    margin: 0 0.5rem;\n\n    /* OPTIONAL: Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\n.pricing-table {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.pricing-table__column {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    margin: 0 0.25rem;\n    padding: 0.25rem;\n\n    width: 16rem;\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n}\n```\n\n```html index.html hidden\n<div class=\"pricing-table\">\n    <div class=\"pricing-table__column\">\n        <div class=\"circle circle--md\"></div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n    </div>\n    <div class=\"pricing-table__column\">\n        <div class=\"circle circle--md\"></div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/progress-bar.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-11-17'\ndescription: Create a progress bar with CSS flexbox\nkeywords: css flexbox, css progress bar\nthumbnail: /assets/css-layout/thumbnails/progress-bar.png\ntitle: Progress bar\n---\n\n## HTML\n\n```html index.html\n<div class=\"container\">\n    <!-- Width based on the number of percentages -->\n    <div class=\"container__progress\" style=\"width: 40%;\">\n        <!-- The number of percentages -->\n        40%\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.progress-bar {\n    /* Colors */\n    background-color: #d1d5db;\n\n    /* Rounded border */\n    border-radius: 9999px;\n    padding: 0.25rem;\n}\n\n.progress-bar__progress {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Colors */\n    background-color: #3b82f6;\n    color: #fff;\n\n    /* Rounded border */\n    border-radius: 9999px;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.progress-bar {\n    /* Colors */\n    background-color: #d1d5db;\n\n    /* Rounded border */\n    border-radius: 9999px;\n    padding: 0.25rem;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.progress-bar__progress {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Colors */\n    background-color: #3b82f6;\n    color: #fff;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    width: 40%;\n}\n```\n\n```html index.html hidden\n<div class=\"progress-bar\">\n    <div class=\"progress-bar__progress\">40%</div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Indeterminate progress bar](https://phuoc.ng/collection/css-layout/indeterminate-progress-bar/)\n"
  },
  {
    "path": "contents/property-list.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-25'\ndescription: Create a property list with CSS flexbox\nkeywords: css flexbox, property list\nthumbnail: /assets/css-layout/thumbnails/property-list.png\ntitle: Property list\n---\n\n## HTML\n\n```html index.html\n<!-- A property item -->\n<dl class=\"property-list\">\n    <!-- Property name -->\n    <dt class=\"property-list__key\">...</dt>\n\n    <!-- Property value -->\n    <dd class=\"property-list__value\">...</dd>\n</dl>\n\n<!-- Repeat other items -->\n...\n```\n\n## CSS\n\n```css styles.css\n.property-list {\n    /* Content is center horizontally */\n    align-items: center;\n    display: flex;\n\n    border-bottom: 1px solid #d1d5db;\n\n    /* Spacing */\n    margin: 0;\n    padding: 0.25rem 0;\n}\n.property-list__key {\n    /* Take the available width */\n    flex: 1;\n}\n.property-list__value {\n    margin-left: 0.5rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.property-list {\n    /* Content is center horizontally */\n    align-items: center;\n    display: flex;\n\n    border-bottom: 1px solid #d1d5db;\n\n    /* Spacing */\n    margin: 0;\n    padding: 0.5rem 0;\n\n    width: 16rem;\n}\n.property-list__key {\n    /* Take the remaining width */\n    flex: 1;\n}\n.property-list__value {\n    margin-left: 0.5rem;\n}\n```\n\n```html index.html hidden\n<dl class=\"property-list\">\n    <dt class=\"property-list__key\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--20\"></div></dt>\n    <dd class=\"property-list__value\"><div class=\"circle circle--sm\"></div></dd>\n</dl>\n\n<dl class=\"property-list\">\n    <dt class=\"property-list__key\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--60\"></div></dt>\n    <dd class=\"property-list__value\"><div class=\"circle circle--sm\"></div></dd>\n</dl>\n\n<dl class=\"property-list\">\n    <dt class=\"property-list__key\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--40\"></div></dt>\n    <dd class=\"property-list__value\"><div class=\"circle circle--sm\"></div></dd>\n</dl>\n\n<dl class=\"property-list\">\n    <dt class=\"property-list__key\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--80\"></div></dt>\n    <dd class=\"property-list__value\"><div class=\"circle circle--sm\"></div></dd>\n</dl>\n```\n</Playground>\n"
  },
  {
    "path": "contents/questions-and-answers.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-23'\ndescription: Create a questions and answers section with CSS flexbox\nkeywords: css accordion, css faq, css flexbox\nthumbnail: /assets/css-layout/thumbnails/questions-and-answers.png\ntitle: Questions and answers\n---\n\n## HTML\n\n```html index.html\n<!-- Collapsed question and answer item -->\n<div class=\"questions-and-answers__item questions-and-answers__item--collapsed\">\n    <!-- Heading -->\n    <div class=\"questions-and-answers__header\">\n        <!-- Question -->\n        <div class=\"questions-and-answers__title\">...</div>\n\n        <!-- The toggle icon sticks to the right -->\n        <div class=\"questions-and-answers__toggle\"></div>\n    </div>\n\n    <!-- Answer -->\n    <div class=\"questions-and-answers__content\">...</div>\n</div>\n\n<!-- Expanded question and answer item -->\n<div class=\"questions-and-answers__item questions-and-answers__item--expanded\">...</div>\n```\n\n## CSS\n\n```css styles.css\n.questions-and-answers__item:not(:last-child) {\n    border-bottom: 1px solid #d1d5db;\n}\n.questions-and-answers__header {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    cursor: pointer;\n    padding: 0.5rem;\n}\n.questions-and-answers__toggle {\n    margin-right: 0.25rem;\n}\n.questions-and-answers__title {\n    /* Take the available width */\n    flex: 1;\n}\n.questions-and-answers__content {\n    padding: 0 0.5rem;\n}\n\n.questions-and-answers__item--collapsed .questions-and-answers__content {\n    display: none;\n}\n.questions-and-answers__item--expanded .questions-and-answers__content {\n    display: block;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.questions-and-answers {\n    width: 16rem;\n}\n.questions-and-answers__item:not(:last-child) {\n    border-bottom: 1px solid #d1d5db;\n}\n.questions-and-answers__header {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    cursor: pointer;\n    padding: 0.5rem;\n}\n.questions-and-answers__toggle {\n    margin-right: 0.25rem;\n}\n.questions-and-answers__title {\n    flex: 1;\n}\n.questions-and-answers__content {\n    padding: 0 0.5rem;\n}\n\n.questions-and-answers__item--collapsed .questions-and-answers__content {\n    display: none;\n}\n.questions-and-answers__item--expanded .questions-and-answers__content {\n    display: block;\n}\n```\n\n```html index.html hidden\n<div class=\"questions-and-answers\">\n    <div class=\"questions-and-answers__item questions-and-answers__item--collapsed\">\n        <div class=\"questions-and-answers__header\">\n            <div class=\"questions-and-answers__title\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </div>\n            <div class=\"questions-and-answers__toggle\">\n                <div class=\"triangle triangle--r triangle--sm\"></div>\n            </div>\n        </div>\n    </div>\n    <div class=\"questions-and-answers__item questions-and-answers__item--expanded\">\n        <div class=\"questions-and-answers__header\">\n            <div class=\"questions-and-answers__title\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </div>\n            <div class=\"questions-and-answers__toggle\">\n                <div class=\"triangle triangle--b triangle--sm\"></div>\n            </div>\n        </div>\n        <div class=\"questions-and-answers__content\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n    </div>\n    <div class=\"questions-and-answers__item questions-and-answers__item--collapsed\">\n        <div class=\"questions-and-answers__header\">\n            <div class=\"questions-and-answers__title\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </div>\n            <div class=\"questions-and-answers__toggle\">\n                <div class=\"triangle triangle--r triangle--sm\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/radial-progress-bar.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-11-30'\ndescription: Create a radial progress bar with CSS flexbox\nkeywords: css clip rect, css flexbox, css progress bar\nthumbnail: /assets/css-layout/thumbnails/radial-progress-bar.png\ntitle: Radial progress bar\n---\n\n## HTML\n\n```html index.html\n<div class=\"radial-progress-bar\">\n    <!-- Show number of percentages -->\n    <div class=\"radial-progress-bar__percentages\">...</div>\n\n    <!-- The curve -->\n    <div class=\"radial-progress-bar__curve\">\n        <!-- The first half -->\n        <div class=\"radial-progress-bar__half radial-progress-bar__half--first\"></div>\n\n        <!-- The second half -->\n        <div class=\"radial-progress-bar__half radial-progress-bar__half--second\"></div>\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n:root {\n    --radial-progress-bar-size: 8rem;\n    --radial-progress-bar-border-width: 0.75rem;\n}\n\n.radial-progress-bar {\n    position: relative;\n    height: var(--radial-progress-bar-size);\n    width: var(--radial-progress-bar-size);\n}\n\n.radial-progress-bar__percentages {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Rounded border */\n    border: var(--radial-progress-bar-border-width) solid #d1d5db;\n    border-radius: 9999px;\n\n    /* Size */\n    height: 100%;\n    width: 100%;\n}\n\n.radial-progress-bar__curve {\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* If percentages is less than 50 */\n    /* clip: rect(\n        0px,\n        var(--radial-progress-bar-size),\n        var(--radial-progress-bar-size),\n        calc(var(--radial-progress-bar-size) * 0.5),\n        0px\n    ); */\n\n    /* If percentages is greater than or equals to 50 */\n    clip: rect(auto, auto, auto, auto);\n}\n\n.radial-progress-bar__half {\n    /* Take full size */\n    height: 100%;\n    position: absolute;\n    width: 100%;\n\n    /*\n    Background color of curve.\n    The border width should be the same as the area showing the percentages\n    */\n    border: var(--radial-progress-bar-border-width) solid #3b82f6;\n    border-radius: 9999px;\n}\n\n.radial-progress-bar__half--first {\n    /* Position */\n    clip: rect(0px, calc(var(--radial-progress-bar-size) * 0.5), var(--radial-progress-bar-size), 0px);\n\n    /* Number of percentages * 360 / 100 */\n    transform: rotate(270deg);\n}\n\n.radial-progress-bar__half--second {\n    /* Position */\n    clip: rect(0px, calc(var(--radial-progress-bar-size) * 0.5), var(--radial-progress-bar-size), 0px);\n\n    /* If percentages is less than 50 */\n    /* transform: rotate(0deg); */\n\n    /* If percentages is greater than or equals to 50 */\n    transform: rotate(180deg);\n}\n```\n\n<Playground>\n```css styles.css hidden\n:root {\n    --radial-progress-bar-size: 8rem;\n    --radial-progress-bar-border-width: 0.75rem;\n}\n\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.radial-progress-bar {\n    position: relative;\n    height: var(--radial-progress-bar-size);\n    width: var(--radial-progress-bar-size);\n}\n\n.radial-progress-bar__percentages {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Rounded border */\n    border: var(--radial-progress-bar-border-width) solid #d1d5db;\n    border-radius: 9999px;\n\n    /* Size */\n    height: 100%;\n    width: 100%;\n}\n\n.radial-progress-bar__curve {\n    /* Position */\n    left: 0;\n    position: absolute;\n    top: 0;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* If percentages is less than 50 */\n    // clip: rect(0px, var(--radial-progress-bar-size), var(--radial-progress-bar-size), calc(var(--radial-progress-bar-size) * 0.5), 0px);\n\n    /* If percentages is greater than or equals to 50 */\n    clip: rect(auto, auto, auto, auto);\n}\n\n.radial-progress-bar__half {\n    /* Take full size */\n    height: 100%;\n    position: absolute;\n    width: 100%;\n\n    /*\n    Background color of curve.\n    The border width should be the same as the area showing the percentages\n    */\n    border: var(--radial-progress-bar-border-width) solid #3b82f6;\n    border-radius: 9999px;\n}\n\n.radial-progress-bar__half--first {\n    /* Position */\n    clip: rect(0px, calc(var(--radial-progress-bar-size) * 0.5), var(--radial-progress-bar-size), 0px);\n\n    /* Number of percentages * 360 / 100 */\n    transform: rotate(270deg);\n}\n\n.radial-progress-bar__half--second {\n    /* Position */\n    clip: rect(0px, calc(var(--radial-progress-bar-size) * 0.5), var(--radial-progress-bar-size), 0px);\n\n    /* If percentages is less than 50 */\n    // transform: rotate(0deg);\n\n    /* If percentages is greater than or equals to 50 */\n    transform: rotate(180deg);\n}\n```\n\n```html index.html hidden\n<div class=\"radial-progress-bar\">\n    <div class=\"radial-progress-bar__percentages\">\n        75%\n    </div>\n    <div class=\"radial-progress-bar__curve\">\n        <div class=\"radial-progress-bar__half radial-progress-bar__half--first\"></div>\n        <div class=\"radial-progress-bar__half radial-progress-bar__half--second\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/radio-button-group.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-12-01'\ndescription: Create a radio button group with CSS flexbox\nkeywords: css flexbox, css radio button\nthumbnail: /assets/css-layout/thumbnails/radio-button-group.png\ntitle: Radio button group\n---\n\n## HTML\n\n```html index.html\n<div class=\"radio-button-group\">\n    <!-- Each radio item -->\n    <label class=\"radio-button-group__label\">\n        <!-- The radio input -->\n        <input type=\"radio\" class=\"radio-button-group__input\" />\n\n        <!-- The text -->\n        ...\n    </label>\n\n    <!-- Selected item -->\n    <label class=\"radio-button-group__label radio-button-group__label--selected\"> ... </label>\n\n    <!-- Repeat other items -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.radio-button-group {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 2rem;\n}\n\n.radio-button-group__label {\n    /* Center the content */\n    align-items: center;\n    display: inline-flex;\n\n    border-right: 1px solid #d1d5db;\n    padding: 0.5rem;\n\n    /* For not selected radio */\n    background-color: transparent;\n    color: #ccc;\n}\n\n.radio-button-group__label:last-child {\n    /* Remove the right border from the last label */\n    border-right-color: transparent;\n}\n\n.radio-button-group__label--selected {\n    /* For selected radio */\n    background-color: #3b82f6;\n    color: #fff;\n\n    margin-top: -1px;\n    margin-bottom: -1px;\n}\n\n.radio-button-group__input {\n    /* Hide it */\n    display: none;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.radio-button-group {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 2rem;\n}\n\n.radio-button-group__label {\n    /* Center the content */\n    align-items: center;\n    display: inline-flex;\n\n    border-right: 1px solid #d1d5db;\n    padding: 0.5rem;\n\n    /* For not selected radio */\n    background-color: transparent;\n    color: #ccc;\n}\n\n.radio-button-group__label:last-child {\n    /* Remove the right border from the last label */\n    border-right-color: transparent;\n}\n\n.radio-button-group__label--selected {\n    /* For selected radio */\n    background-color: #3b82f6;\n    color: #fff;\n\n    margin-top: -1px;\n    margin-bottom: -1px;\n}\n\n.radio-button-group__input {\n    /* Hide it */\n    display: none;\n}\n```\n\n```html index.html hidden\n<div class=\"radio-button-group\">\n    <label class=\"radio-button-group__label\">\n        <input type=\"radio\" class=\"radio-button-group__input\" /> S\n    </label>\n    <label class=\"radio-button-group__label radio-button-group__label--selected\">\n        <input type=\"radio\" class=\"radio-button-group__input\" /> M\n    </label>\n    <label class=\"radio-button-group__label\">\n        <input type=\"radio\" class=\"radio-button-group__input\" /> L\n    </label>\n    <label class=\"radio-button-group__label\">\n        <input type=\"radio\" class=\"radio-button-group__input\" /> XL\n    </label>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/radio-switch.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-24'\ndescription: Create a radio switch with CSS flexbox\nkeywords: css flexbox, css radio switch, css switch\nthumbnail: /assets/css-layout/thumbnails/radio-switch.png\ntitle: Radio switch\n---\n\n## HTML\n\n```html index.html\n<div class=\"radio-switch\">\n    <!-- Radio container -->\n    <label class=\"radio-switch__label radio-switch__label--selected\">\n        <input type=\"radio\" class=\"radio-switch__input\" />\n\n        <!-- Text -->\n        ...\n    </label>\n\n    <!-- Other radio item -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.radio-switch {\n    background-color: #d1d5db;\n    border-radius: 9999px;\n    display: inline-flex;\n    padding: 0.25rem;\n}\n\n.radio-switch__label {\n    border-radius: 9999px;\n    cursor: pointer;\n    padding: 0.25rem 0.5rem;\n}\n\n.radio-switch__label--selected {\n    /* For selected radio only */\n    background-color: #3b82f6;\n    color: #fff;\n}\n\n.radio-switch__input {\n    display: none;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.radio-switch {\n    background-color: #d1d5db;\n    border-radius: 9999px;\n    display: inline-flex;\n    padding: 0.25rem;\n}\n\n.radio-switch__label {\n    border-radius: 9999px;\n    cursor: pointer;\n    padding: 0.25rem 0.5rem;\n}\n\n.radio-switch__label--selected {\n    /* For selected radio only */\n    background-color: #3b82f6;\n    color: #fff;\n}\n\n.radio-switch__input {\n    display: none;\n}\n```\n\n```html index.html hidden\n<div class=\"radio-switch\">\n    <label class=\"radio-switch__label\">\n        <input type=\"radio\" class=\"radio-switch__input\" /> Monthly\n    </label>\n    <label class=\"radio-switch__label radio-switch__label--selected\">\n        <input type=\"radio\" class=\"radio-switch__input\" /> Yearly\n    </label>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/rating.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-26'\ndescription: Create a star rating with CSS flexbox\nkeywords: css flexbox, css star rating\nthumbnail: /assets/css-layout/thumbnails/rating.png\ntitle: Rating\n---\n\n## HTML\n\n```html index.html\n<div class=\"rating\">\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">★</button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.rating {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    flex-direction: row-reverse;\n}\n\n.rating__star:hover,\n.rating__star:hover ~ .rating__star {\n    color: transparent;\n}\n\n/*\nMake all previous stars selected when hover on a star\nNote that we use \\`flex-direction: row-reverse\\` on the container\n*/\n.rating__star:hover:before,\n.rating__star:hover ~ .rating__star:before {\n    color: #eab308;\n    content: '★';\n    left: 0;\n    position: absolute;\n}\n\n.rating__star {\n    font-size: 1.5rem;\n\n    /* Reset styles for button */\n    background-color: transparent;\n    border: transparent;\n    margin: 0 2px;\n    padding: 0;\n\n    /* Used to position the hover state */\n    position: relative;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.rating {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    flex-direction: row-reverse;\n}\n\n.rating__star:hover,\n.rating__star:hover ~ .rating__star {\n    color: transparent;\n}\n\n/*\nMake all previous stars selected when hover on a star\nNote that we use \\`flex-direction: row-reverse\\` on the container\n*/\n.rating__star:hover:before,\n.rating__star:hover ~ .rating__star:before {\n    color: #eab308;\n    content: '★';\n    left: 0;\n    position: absolute;\n}\n\n.rating__star {\n    font-size: 1.5rem;\n\n    /* Reset styles for button */\n    background-color: transparent;\n    border: transparent;\n    margin: 0 2px;\n    padding: 0;\n\n    /* Used to position the hover state */\n    position: relative;\n}\n```\n\n```html index.html hidden\n<div class=\"rating\">\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">☆</button>\n    <button class=\"rating__star\">★</button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/resizable-element.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-12-10'\ndescription: Create resizable indicators with CSS\nkeywords: css resizable, css resize cursor\nthumbnail: /assets/css-layout/thumbnails/resizable-element.png\ntitle: Resizable element\n---\n\n## HTML\n\n```html index.html\n<div class=\"resizable-element\">\n    <!-- The content -->\n    ...\n\n    <!-- The top left square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--tl\"></div>\n\n    <!-- The top square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--tc\"></div>\n\n    <!-- The top right square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--tr\"></div>\n\n    <!-- The right square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--rc\"></div>\n\n    <!-- The right bottom square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--rb\"></div>\n\n    <!-- The bottom square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--bc\"></div>\n\n    <!-- The bottom left square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--bl\"></div>\n\n    <!-- The left square -->\n    <div class=\"resizable-element__resizer resizable-element__resizer--lc\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.resizable-element {\n    /* Border */\n    border: 1px dashed #d1d5db;\n\n    /* Used to position the squares */\n    position: relative;\n}\n\n.resizable-element__resizer {\n    /* Border */\n    border: 1px solid #d1d5db;\n    position: absolute;\n\n    /* Size */\n    height: 0.75rem;\n    width: 0.75rem;\n}\n\n.resizable-element__resizer--tl {\n    /* Resize cursor */\n    cursor: nwse-resize;\n\n    /* Positioned at the top left corner */\n    left: 0px;\n    top: 0px;\n    transform: translate(-50%, -50%);\n}\n\n.resizable-element__resizer--tc {\n    /* Resize cursor */\n    cursor: ns-resize;\n\n    /* Positioned at the middle of top side */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, -50%);\n}\n\n.resizable-element__resizer--tr {\n    /* Resize cursor */\n    cursor: nesw-resize;\n\n    /* Positioned at the top right corner */\n    right: 0px;\n    top: 0px;\n    transform: translate(50%, -50%);\n}\n\n.resizable-element__resizer--rc {\n    /* Resize cursor */\n    cursor: ew-resize;\n\n    /* Positioned at the middle of right side */\n    right: 0px;\n    top: 50%;\n    transform: translate(50%, -50%);\n}\n\n.resizable-element__resizer--rb {\n    /* Resize cursor */\n    cursor: nwse-resize;\n\n    /* Positioned at the right bottom corner */\n    bottom: 0px;\n    right: 0px;\n    transform: translate(50%, 50%);\n}\n\n.resizable-element__resizer--bc {\n    /* Resize cursor */\n    cursor: ns-resize;\n\n    /* Positioned at the middle of bottom side */\n    bottom: 0px;\n    right: 50%;\n    transform: translate(50%, 50%);\n}\n\n.resizable-element__resizer--bl {\n    /* Resize cursor */\n    cursor: nesw-resize;\n\n    /* Positioned at the bottom left corner */\n    bottom: 0px;\n    left: 0px;\n    transform: translate(-50%, 50%);\n}\n\n.resizable-element__resizer--lc {\n    /* Resize cursor */\n    cursor: ew-resize;\n\n    /* Positioned at the middle of left side */\n    left: 0px;\n    top: 50%;\n    transform: translate(-50%, -50%);\n}\n```\n\nYou can move the mouse over each squares located at the corners and the middle of sides to see the cursors which indicate the associated side can be resized.\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    height: 24rem;\n}\n\n.resizable-element {\n    /* Border */\n    border: 1px dashed #d1d5db;\n\n    /* Used to position the squares */\n    position: relative;\n\n    /* Demo */\n    height: 16rem;\n    width: 16rem;\n}\n\n.resizable-element__resizer {\n    /* Border */\n    border: 1px solid #d1d5db;\n    position: absolute;\n\n    /* Size */\n    height: 0.75rem;\n    width: 0.75rem;\n}\n\n.resizable-element__resizer--tl {\n    /* Resize cursor */\n    cursor: nwse-resize;\n\n    /* Positioned at the top left corner */\n    left: 0px;\n    top: 0px;\n    transform: translate(-50%, -50%);\n}\n\n.resizable-element__resizer--tc {\n    /* Resize cursor */\n    cursor: ns-resize;\n\n    /* Positioned at the middle of top side */\n    left: 50%;\n    top: 0px;\n    transform: translate(-50%, -50%);\n}\n\n.resizable-element__resizer--tr {\n    /* Resize cursor */\n    cursor: nesw-resize;\n\n    /* Positioned at the top right corner */\n    right: 0px;\n    top: 0px;\n    transform: translate(50%, -50%);\n}\n\n.resizable-element__resizer--rc {\n    /* Resize cursor */\n    cursor: ew-resize;\n\n    /* Positioned at the middle of right side */\n    right: 0px;\n    top: 50%;\n    transform: translate(50%, -50%);\n}\n\n.resizable-element__resizer--rb {\n    /* Resize cursor */\n    cursor: nwse-resize;\n\n    /* Positioned at the right bottom corner */\n    bottom: 0px;\n    right: 0px;\n    transform: translate(50%, 50%);\n}\n\n.resizable-element__resizer--bc {\n    /* Resize cursor */\n    cursor: ns-resize;\n\n    /* Positioned at the middle of bottom side */\n    bottom: 0px;\n    right: 50%;\n    transform: translate(50%, 50%);\n}\n\n.resizable-element__resizer--bl {\n    /* Resize cursor */\n    cursor: nesw-resize;\n\n    /* Positioned at the bottom left corner */\n    bottom: 0px;\n    left: 0px;\n    transform: translate(-50%, 50%);\n}\n\n.resizable-element__resizer--lc {\n    /* Resize cursor */\n    cursor: ew-resize;\n\n    /* Positioned at the middle of left side */\n    left: 0px;\n    top: 50%;\n    transform: translate(-50%, -50%);\n}\n```\n\n```html index.html hidden\n<div class=\"resizable-element\">\n    <div class=\"resizable-element__resizer resizable-element__resizer--tl\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--tc\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--tr\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--rc\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--rb\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--bc\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--bl\"></div>\n    <div class=\"resizable-element__resizer resizable-element__resizer--lc\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/ribbon.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-01'\ndescription: Create a ribbon with CSS\nkeywords: css ribbon\nthumbnail: /assets/css-layout/thumbnails/ribbon.png\ntitle: Ribbon\n---\n\n## HTML\n\n```html index.html\n<div class=\"ribbon\">\n    <!-- The left side -->\n    <div class=\"ribbon__side ribbon__side--l\"></div>\n\n    <!-- The left triangle displayed below the content -->\n    <div class=\"ribbon__triangle ribbon__triangle--l\"></div>\n\n    <!-- The right triangle displayed below the content -->\n    <div class=\"ribbon__triangle ribbon__triangle--r\"></div>\n\n    <!-- The right side -->\n    <div class=\"ribbon__side ribbon__side--r\"></div>\n\n    <!-- The content -->\n    <div class=\"ribbon__content\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.ribbon {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 2rem;\n\n    /* Use to position the corners */\n    position: relative;\n}\n\n.ribbon__content {\n    /* Background color */\n    background-color: #9ca3af;\n    z-index: 1;\n\n    height: 100%;\n    width: 100%;\n}\n.ribbon__side {\n    bottom: -0.5rem;\n    position: absolute;\n\n    /* Displayed under the ribbon */\n    z-index: 1;\n\n    /* Background */\n    border: 1rem solid #d1d5db;\n}\n\n.ribbon__side--l {\n    /* Position */\n    left: -1.5rem;\n    border-color: #d1d5db #d1d5db #d1d5db transparent;\n}\n\n.ribbon__side--r {\n    /* Position */\n    right: -1.5rem;\n    border-color: #d1d5db transparent #d1d5db #d1d5db;\n}\n\n.ribbon__triangle {\n    position: absolute;\n    top: 100%;\n\n    border: 0.5rem solid transparent;\n    border-bottom-width: 0;\n    border-top-color: #aaa;\n}\n\n.ribbon__triangle--l {\n    border-right-width: 0;\n    left: 0;\n}\n\n.ribbon__triangle--r {\n    border-left-width: 0;\n    right: 0;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.ribbon {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 2rem;\n    width: 4rem; /* For demo */\n\n    /* Use to position the corners */\n    position: relative;\n}\n\n.ribbon__content {\n    /* Background color */\n    background-color: #9ca3af;\n    z-index: 1;\n\n    height: 100%;\n    width: 100%;\n}\n.ribbon__side {\n    bottom: -0.5rem;\n    position: absolute;\n\n    /* Background */\n    border: 1rem solid #d1d5db;\n}\n\n.ribbon__side--l {\n    /* Position */\n    left: -1.5rem;\n    border-color: #d1d5db #d1d5db #d1d5db transparent;\n}\n\n.ribbon__side--r {\n    /* Position */\n    right: -1.5rem;\n    border-color: #d1d5db transparent #d1d5db #d1d5db;\n}\n\n.ribbon__triangle {\n    position: absolute;\n    top: 100%;\n\n    border: 0.5rem solid transparent;\n    border-bottom-width: 0;\n    border-top-color: #6b7280;\n    z-index: 1;\n}\n\n.ribbon__triangle--l {\n    border-right-width: 0;\n    left: 0;\n}\n\n.ribbon__triangle--r {\n    border-left-width: 0;\n    right: 0;\n}\n```\n\n```html index.html hidden\n<div class=\"ribbon\">\n    <div class=\"ribbon__side ribbon__side--l\"></div>\n    <div class=\"ribbon__triangle ribbon__triangle--l\"></div>\n    <div class=\"ribbon__triangle ribbon__triangle--r\"></div>\n    <div class=\"ribbon__side ribbon__side--r\"></div>\n    <div class=\"ribbon__content\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/same-height-columns.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-17'\ndescription: Create same height columns with CSS flexbox\nkeywords: css flexbox, css layout, css same height columns\nthumbnail: /assets/css-layout/thumbnails/same-height-columns.png\ntitle: Same height columns\n---\n\n## HTML\n\n```html index.html\n<div class=\"same-height-columns\">\n    <!-- Column -->\n    <div class=\"same-height-columns__column\">\n        <!-- Cover -->\n        ...\n\n        <!-- Content -->\n        <div class=\"same-height-columns__content\">...</div>\n\n        <!-- Button sticks to the bottom -->\n        ...\n    </div>\n\n    <!-- Repeat with other columns -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.same-height-columns {\n    display: flex;\n}\n\n.same-height-columns__column {\n    flex: 1;\n    /* Space between columns */\n    margin: 0 8px;\n\n    /* Layout each column */\n    display: flex;\n    flex-direction: column;\n}\n\n.same-height-columns__content {\n    /* Take available height */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.same-height-columns {\n    display: flex;\n\n    /* Demo */\n    width: 100%;\n    height: 100%;\n}\n\n.same-height-columns__column {\n    flex: 1;\n    /* Space between columns */\n    margin: 0 0.25rem;\n\n    /* Layout each column */\n    display: flex;\n    flex-direction: column;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem;\n}\n\n.same-height-columns__content {\n    /* Take available height */\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"same-height-columns\">\n    <div class=\"same-height-columns__column\">\n        <div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div>\n        <div class=\"same-height-columns__content\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n\n    <div class=\"same-height-columns__column\">\n        <div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div>\n        <div class=\"same-height-columns__content\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n\n    <div class=\"same-height-columns__column\">\n        <div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div>\n        <div class=\"same-height-columns__content\">\n            <div class=\"lines\">\n                <div class=\"line line--20\"></div>\n                <div class=\"line line--80\"></div>\n                <div class=\"line line--40\"></div>\n                <div class=\"line line--60\"></div>\n                <div class=\"line line--20\"></div>\n            </div>\n        </div>\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/search-box.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-22'\ndescription: Create a search box with CSS flexbox\nkeywords: css flexbox, css search box\nthumbnail: /assets/css-layout/thumbnails/search-box.png\ntitle: Search box\n---\n\n## HTML\n\n```html index.html\n<div class=\"search-box\">\n    <!-- Text input -->\n    <input type=\"text\" class=\"search-box__input\" />\n\n    <!-- Search icon sticks to the left or right -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.search-box {\n    display: flex;\n\n    /* If you want to place the icon before the text input */\n    flex-direction: row-reverse;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n}\n\n.search-box__input {\n    border-color: transparent;\n    /* Take available width */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.search-box {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    display: flex;\n    align-items: center;\n\n    /* Demo */\n    padding: 0.25rem;\n    width: 16rem;\n}\n\n.search-box__input {\n    border-color: transparent;\n\n    /* Take available width */\n    flex: 1;\n\n    height: 2rem;\n    margin-right: 0.25rem;\n\n    /* Demo */\n    width: 6rem;\n}\n```\n\n```html index.html hidden\n<div class=\"search-box\">\n    <input type=\"text\" class=\"search-box__input\" />\n    <div class=\"circle circle--md\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/separator.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-11-21'\ndescription: Create a separator with CSS flexbox\nkeywords: css divider, css flexbox, css separator\nthumbnail: /assets/css-layout/thumbnails/separator.png\ntitle: Separator\n---\n\n## HTML\n\n```html index.html\n<div class=\"separator\">\n    <!-- Text -->\n    <div class=\"separator__content\">...</div>\n\n    <!-- Separator line -->\n    <div class=\"separator__separator\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.separator {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Used to set the position of text */\n    position: relative;\n}\n\n.separator__content {\n    /* We won't see the separator line */\n    background: #fff;\n\n    /* Displayed at the center of separator */\n    left: 50%;\n    position: absolute;\n    top: 50%;\n    transform: translate(-50%, -50%);\n\n    /* Spacing */\n    padding: 0 0.25rem;\n\n    /* Demo */\n    width: 60%;\n}\n\n.separator__separator {\n    border-bottom: 1px solid #d1d5db;\n    height: 1px;\n    width: 100%;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.separator {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Used to set the position of text */\n    position: relative;\n\n    /* Demo */\n    width: 20rem;\n}\n\n.separator__content {\n    /* We won't see the separator line */\n    background: #fff;\n\n    /* Displayed at the center of separator */\n    left: 50%;\n    position: absolute;\n    top: 50%;\n    transform: translate(-50%, -50%);\n\n    /* Spacing */\n    padding: 0 0.25rem;\n\n    /* Demo */\n    width: 60%;\n}\n\n.separator__separator {\n    border-bottom: 1px solid #d1d5db;\n    height: 1px;\n    width: 100%;\n}\n```\n\n```html index.html hidden\n<div class=\"separator\">\n    <div class=\"separator__content\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></div>\n    <div class=\"separator__separator\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/sidebar.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-16'\ndescription: Create a sidebar with CSS flexbox\nkeywords: css flexbox, css layout, css sidebar\nthumbnail: /assets/css-layout/thumbnails/sidebar.png\ntitle: Sidebar\n---\n\n## HTML\n\n```html index.html\n<div class=\"sidebar\">\n    <!-- Sidebar -->\n    <aside class=\"sidebar__sidebar\">...</aside>\n\n    <!-- Main -->\n    <main class=\"sidebar__main\">...</main>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.sidebar {\n    display: flex;\n}\n\n.sidebar__sidebar {\n    width: 30%;\n}\n\n.sidebar__main {\n    /* Take the remaining width */\n    flex: 1;\n\n    /* Make it scrollable */\n    overflow: auto;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.sidebar {\n    display: flex;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n}\n\n.sidebar__sidebar {\n    border-right: 1px solid #d1d5db;\n    width: 30%;\n\n    /* Demo */\n    display: flex;\n    flex-direction: column;\n    justify-content: flex-end;\n}\n\n.sidebar__main {\n    /* Take the remaining width */\n    flex: 1;\n\n    /* Make it scrollable */\n    overflow: auto;\n}\n```\n\n```html index.html hidden\n<div class=\"sidebar\">\n    <div class=\"sidebar__sidebar\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"sidebar__main\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/simple-grid.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-22'\ndescription: Create a simple grid with CSS flexbox\nkeywords: css flexbox, css flexbox grid, css grid, css layout\nthumbnail: /assets/css-layout/thumbnails/simple-grid.png\ntitle: Simple grid\n---\n\n## HTML\n\n```html index.html\n<!-- Row -->\n<div class=\"simple-grid\">\n    <!--Cell with given width. Replace 25% with whatever you want -->\n    <div class=\"simple-grid__cell simple-grid__cell--1/4\">25%</div>\n\n    <!-- Cell that takes remaining width -->\n    <div class=\"simple-grid__cell simple-grid__cell--fill\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.simple-grid {\n    display: flex;\n\n    margin-left: -0.25rem;\n    margin-right: -0.25rem;\n}\n\n.simple-grid__cell {\n    padding-left: 0.25rem;\n    padding-right: 0.25rem;\n}\n\n.simple-grid__cell--fill {\n    flex: 1;\n}\n\n/* Cell with given width */\n.simple-grid__cell--1\\/2 {\n    flex: 0 0 50%;\n}\n.simple-grid__cell--1\\/3 {\n    flex: 0 0 33.3333333%;\n}\n.simple-grid__cell--1\\/4 {\n    flex: 0 0 25%;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\n.simple-grid {\n    display: flex;\n\n    margin-left: -0.25rem;\n    margin-right: -0.25rem;\n\n    /* Demo */\n    margin-bottom: 0.25em;\n    margin-top: 0.25em;\n    height: 4rem;\n    width: 100%;\n}\n\n.simple-grid__cell {\n    padding-left: 0.25rem;\n    padding-right: 0.25rem;\n}\n\n/* Cell with given width */\n.simple-grid__cell--1\\/2 {\n    flex: 0 0 50%;\n}\n.simple-grid__cell--1\\/3 {\n    flex: 0 0 33.3333333%;\n}\n.simple-grid__cell--1\\/4 {\n    flex: 0 0 25%;\n}\n\n.simple-grid__cell--fill {\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"simple-grid\">\n    <div class=\"simple-grid__cell simple-grid__cell--1/4\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"simple-grid__cell simple-grid__cell--fill\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n</div>\n<div class=\"simple-grid\">\n    <div class=\"simple-grid__cell simple-grid__cell--1/3\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"simple-grid__cell simple-grid__cell--1/3\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"simple-grid__cell simple-grid__cell--1/3\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n</div>\n<div class=\"simple-grid\">\n    <div class=\"simple-grid__cell simple-grid__cell--1/4\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"simple-grid__cell simple-grid__cell--1/4\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"simple-grid__cell simple-grid__cell--1/4\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n    <div class=\"simple-grid__cell simple-grid__cell--1/4\"><div class=\"rectangle rectangle--hor rectangle--md rectangle--100\"></div></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/slider.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-17'\ndescription: Create a slider with CSS flexbox\nkeywords: css flexbox, css slider\nthumbnail: /assets/css-layout/thumbnails/slider.png\ntitle: Slider\n---\n\n## HTML\n\n```html index.html\n<div class=\"slider\">\n    <!-- Left side -->\n    <!-- Width based on the current value -->\n    <div class=\"slider__left\" style=\"width: 20%\"></div>\n\n    <!-- Circle -->\n    <div class=\"slider__circle\"></div>\n\n    <!-- Right side -->\n    <div class=\"slider__right\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.slider {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Size */\n    height: 2rem;\n}\n\n.slider__left {\n    height: 2px;\n\n    /* Colors */\n    background-color: #d1d5db;\n}\n\n.slider__circle {\n    /* Size */\n    height: 2rem;\n    width: 2rem;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Colors */\n    background-color: #3b82f6;\n}\n\n.slider__right {\n    /* Take the remaining width */\n    flex: 1;\n    height: 2px;\n\n    /* Colors */\n    background-color: #d1d5db;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.slider {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Size */\n    height: 2rem;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.slider__left {\n    height: 2px;\n\n    /* Colors */\n    background-color: #d1d5db;\n}\n\n.slider__circle {\n    /* Size */\n    height: 2rem;\n    width: 2rem;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Colors */\n    background-color: #3b82f6;\n}\n\n.slider__right {\n    /* Take the remaining width */\n    flex: 1;\n    height: 2px;\n\n    /* Colors */\n    background-color: #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"slider\">\n    <div class=\"slider__left\" style=\"width: 20%\"></div>\n    <div class=\"slider__circle\"></div>\n    <div class=\"slider__right\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/speech-bubble.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-08-31'\ndescription: Create a speech bubble in CSS\nkeywords: css speech bubble\nopenGraphCover: /og/css-layout/speech-bubble.png\nthumbnail: /assets/css-layout/thumbnails/speech-bubble.png\ntitle: Speech bubble\n---\n\nSpeech bubbles are a popular and effective way to show dialogue or thoughts in a visual way. You've probably seen them in comics, cartoons, ads, and social media posts. They add humor, emotion, and personality to a design while also giving context to the viewer. Plus, speech bubble layouts can make text-heavy designs more engaging by breaking them up.\n\nIn this post, we'll learn how to make a speech bubble layout using CSS. Let's get started!\n\n## Markup\n\nYou only need to provide one element to add the speed bubble effect.\n\n```html\n<div class=\"speech-bubble\">\n    <!-- Content goes here -->\n</div>\n```\n\n## Adding a triangle\n\nTo create a speech bubble, we can display a triangle at the bottom-left corner of the container. Rather than adding an external element to the container, we can create the triangle using the `::before` pseudo-element. Here's an example to help you visualize it:\n\n```css\n.speech-bubble {\n    position: relative;\n}\n.speech-bubble::before {\n    content: '';\n\n    position: absolute;\n    bottom: 0;\n    left: -1rem;\n\n    border-width: 1rem;\n    border-style: solid;\n    border-color:\n        transparent transparent rgb(226 232 240) transparent;\n}\n```\n\nFirst, we set the `position` property of the container to `relative`. This allowed us to position the triangle using absolute positioning.\n\nBut the real magic comes from the `::before` pseudo-element. We used the `content` property to add an empty string to this element. That may seem weird, but it's necessary because pseudo-elements require content to be displayed. To position the triangle where we wanted it, we used the `bottom` and `left` properties. By setting the `left` property to a negative value, we moved half of the triangle outside of the container.\n\nFinally, we created the triangle shape by setting the `border-color` property to transparent for the top, left, and right borders. This made the perfect triangle we were looking for.\n\nIf you want to change the direction or position of the triangle, it's easy to do by following this [post](https://phuoc.ng/collection/css-layout/triangle-buttons/).\n\nLet's take a moment to review the progress we've made with these steps.\n\n<Playground>\n```css demo.css hidden\n.playground__root {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 16rem;\n}\n```\n\n```css\n:root {\n    --speech-bubble-background: rgb(226 232 240);\n    --speech-bubble-arrow-size: 1rem;\n}\n.speech-bubble {\n    position: relative;\n\n    background: var(--speech-bubble-background);\n    border-radius: 0.25rem;\n    height: 4rem;\n    width: 12rem;\n}\n.speech-bubble::before {\n    content: '';\n\n    position: absolute;\n    bottom: 0;\n    left: calc(-1 * var(--speech-bubble-arrow-size));\n\n    border-width: var(--speech-bubble-arrow-size);\n    border-style: solid;\n    border-color: transparent transparent\n                var(--speech-bubble-background) transparent;\n}\n```\n\n```html\n<div class=\"speech-bubble\"></div>\n```\n</Playground>\n\n## Using two pseudo-elements\n\nIn the previous section, we used the `::before` pseudo-element to create a triangle. Now, let's take it a step further and create two circles using the `::before` and `::after` pseudo-elements.\n\nTake a look at the demo below to see how it looks:\n\n<Playground>\n```css demo.css hidden\n.playground__root {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    height: 16rem;\n}\n```\n\n```css\n:root {\n    --speech-bubble-background: rgb(226 232 240);\n}\n.speech-bubble {\n    position: relative;\n\n    background: var(--speech-bubble-background);\n    border-radius: 9999px;\n    height: 4rem;\n    width: 12rem;\n}\n.speech-bubble::before,\n.speech-bubble::after {\n    content: '';\n\n    position: absolute;\n    bottom: 0;\n    left: 0;\n\n    border-radius: 9999px;\n    background: var(--speech-bubble-background);\n}\n.speech-bubble::before {\n    height: 1.5rem;\n    width: 1.5rem;\n    transform: translate(-0.5rem, 0.5rem);\n}\n.speech-bubble::after {\n    height: 0.75rem;\n    width: 0.75rem;\n    transform: translate(-1rem, 1rem);\n}\n```\n\n```html\n<div class=\"speech-bubble\"></div>\n```\n</Playground>\n\nTo achieve this, we position both pseudo-elements absolutely at the bottom-left corner of the container, just like in the previous example.\n\n```css\n.speech-bubble::before,\n.speech-bubble::after {\n    content: '';\n    position: absolute;\n    bottom: 0;\n    left: 0;\n}\n```\n\nHowever, each of them is positioned differently by using the `transform` property. Let's take a closer look at the `transform` declaration for the `::before` pseudo-element. The first and second numbers move the element along the horizontal (X) and vertical (Y) axis, respectively.\n\n```css\n.speech-bubble::before {\n    transform: translate(-0.5rem, 0.5rem);\n}\n```\n\n## See also\n\n-   [Popover arrow](https://phuoc.ng/collection/css-layout/popover-arrow/)\n-   [Typing indicator](https://phuoc.ng/collection/css-animation/typing-indicator/)\n-   [Triangle buttons](https://phuoc.ng/collection/css-layout/triangle-buttons/)\n"
  },
  {
    "path": "contents/spin-button.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-25'\ndescription: Create a spin button with CSS flexbox\nkeywords: css flexbox, css spin button\nthumbnail: /assets/css-layout/thumbnails/spin-button.png\ntitle: Spin button\n---\n\n## HTML\n\n```html index.html\n<div class=\"spin-button\">\n    <!-- Input -->\n    <input type=\"text\" class=\"spin-button__input\" />\n\n    <!-- Buttons spin-button -->\n    <div class=\"spin-button__buttons\">\n        <!-- Up button -->\n        <button class=\"spin-button__button\">...</button>\n\n        <!-- Down button -->\n        <button class=\"spin-button__button\">...</button>\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.spin-button {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    display: flex;\n    overflow: hidden;\n}\n\n.spin-button__input {\n    border-color: transparent;\n    padding: 0.5rem;\n\n    /* Demo */\n    width: 8rem;\n}\n\n.spin-button__buttons {\n    /* Content is centered vertically */\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n\n    /* Left border */\n    border-left: 1px solid #d1d5db;\n}\n\n.spin-button__button {\n    /* Reset */\n    background: #fff;\n    border-color: transparent;\n    cursor: pointer;\n\n    /* Make buttons have the same height */\n    flex: 1;\n}\n```\n\nYou can use the [triangle buttons](https://phuoc.ng/collection/css-layout/triangle-buttons/) to create the up and down buttons:\n\n<Playground>\n```css placeholders.css hidden\n.triangle {\n    border-style: solid;\n    height: 0;\n    width: 0;\n}\n.triangle--t {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) var(--triangle-size);\n}\n.triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 var(--triangle-size) 1rem;\n}\n.triangle--b {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 var(--triangle-size);\n}\n.triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: var(--triangle-size) 1rem var(--triangle-size) 0;\n}\n.triangle--tr {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0 var(--triangle-size) var(--triangle-size) 0;\n}\n.triangle--br {\n    border-color: transparent transparent #d1d5db transparent;\n    border-width: 0 0 var(--triangle-size) var(--triangle-size);\n}\n.triangle--bl {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: var(--triangle-size) 0 0 var(--triangle-size);\n}\n.triangle--tl {\n    border-color: #d1d5db transparent transparent transparent;\n    border-width: var(--triangle-size) var(--triangle-size) 0 0;\n}\n.triangle--sm {\n    --triangle-size: 0.5rem;\n}\n.triangle--md {\n    --triangle-size: 2rem;\n}\n.triangle--lg {\n    --triangle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.spin-button {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    display: flex;\n    overflow: hidden;\n}\n\n.spin-button__input {\n    border-color: transparent;\n    padding: 0.5rem;\n\n    /* Demo */\n    width: 8rem;\n}\n\n.spin-button__buttons {\n    /* Content is centered vertically */\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n\n    /* Left border */\n    border-left: 1px solid #d1d5db;\n}\n\n.spin-button__button {\n    /* Reset */\n    background: #fff;\n    border-color: transparent;\n    cursor: pointer;\n\n    /* Make buttons have the same height */\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"spin-button\">\n    <input type=\"text\" class=\"spin-button__input\" />\n    <div class=\"spin-button__buttons\">\n        <button class=\"spin-button__button\">\n            <div class=\"triangle triangle--t triangle--sm\">\n        </button>\n        <button class=\"spin-button__button\">\n            <div class=\"triangle triangle--b triangle--sm\">\n        </button>\n    </div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Build a spin input](https://phuoc.ng/collection/html-dom/build-a-spin-input/)\n"
  },
  {
    "path": "contents/spinner.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2022-10-03'\ndescription: Create a loading spinner with CSS\nkeywords: css loading spinner, css spinner\nthumbnail: /assets/css-layout/thumbnails/spinner.png\ntitle: Spinner\n---\n\n## HTML\n\n```html index.html\n<div class=\"spinner\"></div>\n```\n\n## CSS\n\n```css styles.css\n.spinner {\n    /* Size */\n    height: 4rem;\n    width: 4rem;\n\n    /* Create a curve at the top */\n    border: 4px solid #d1d5db;\n    border-top-color: #3b82f6;\n    border-radius: 50%;\n\n    animation: spinner 800ms linear infinite;\n}\n\n@keyframes spinner {\n    from {\n        transform: rotate(0deg);\n    }\n    to {\n        transform: rotate(360deg);\n    }\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.spinner {\n    height: 4rem;\n    width: 4rem;\n\n    border: 4px solid #d1d5db;\n    border-top-color: #3b82f6;\n    border-radius: 50%;\n\n    animation: spinner 800ms linear infinite;\n}\n\n@keyframes spinner {\n    from {\n        transform: rotate(0deg);\n    }\n    to {\n        transform: rotate(360deg);\n    }\n}\n```\n\n```html index.html hidden\n<div class=\"spinner\"></div>\n```\n</Playground>\n\n## See also\n\n-   [Indeterminate progress bar](https://phuoc.ng/collection/css-layout/indeterminate-progress-bar/)\n"
  },
  {
    "path": "contents/split-navigation.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-22'\ndescription: Create a split navigation with CSS flexbox\nkeywords: css flexbox, css menu, css navigation, css split navigation\nthumbnail: /assets/css-layout/thumbnails/split-navigation.png\ntitle: Split navigation\n---\n\n## HTML\n\n```html index.html\n<ul class=\"split-navigation\">\n    <!-- Navigation item -->\n    <li class=\"split-navigation__item\">\n        <a href=\"\">...</a>\n    </li>\n\n    <!-- Navigation item that sticks to the right -->\n    <li class=\"split-navigation__item split-navigation__item--right\">\n        <a href=\"\">...</a>\n    </li>\n</ul>\n```\n\n## CSS\n\n```css styles.css\n.split-navigation {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0 0 0.5rem 0;\n}\n\n.split-navigation__item {\n    margin-right: 0.25rem;\n\n    /* Demo */\n    width: 1.25rem;\n}\n\n.split-navigation__item--right {\n    /* Sticks to the right */\n    margin-left: auto;\n    margin-right: 0;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.split-navigation {\n    /* Content is centered horizontally */\n    align-items: center;\n    display: flex;\n\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0;\n    padding: 0 0 0.5rem 0;\n\n    /* Demo */\n    border-bottom: 1px solid #d1d5db;\n    width: 16rem;\n}\n\n.split-navigation__item {\n    margin-right: 0.25rem;\n\n    /* Demo */\n    width: 1.25rem;\n}\n\n.split-navigation__item--right {\n    /* Sticks to the right */\n    margin-left: auto;\n    margin-right: 0;\n}\n```\n\n```html index.html hidden\n<ul class=\"split-navigation\">\n    <li class=\"split-navigation__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></li>\n    <li class=\"split-navigation__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></li>\n    <li class=\"split-navigation__item\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></li>\n    <li class=\"split-navigation__item split-navigation__item--right\"><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></li>\n</ul>\n```\n</Playground>\n"
  },
  {
    "path": "contents/split-screen.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-17'\ndescription: Create a split screen with CSS flexbox\nkeywords: css flexbox, css layout, css split screen\nthumbnail: /assets/css-layout/thumbnails/split-screen.png\ntitle: Split screen\n---\n\n## HTML\n\n```html index.html\n<div class=\"split-screen\">\n    <!-- Left content -->\n    <div class=\"split-screen__half\">...</div>\n\n    <!-- Right content -->\n    <div class=\"split-screen__half\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.split-screen {\n    display: flex;\n}\n\n.split-screen__half {\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.split-screen {\n    display: flex;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n}\n\n.split-screen__half {\n    flex: 1;\n\n    /* Demo */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.split-screen__half:first-child {\n    border-right: 1px solid #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"split-screen\">\n    <div class=\"split-screen__half\">\n        <div class=\"circle circle--md\"></div>\n    </div>\n    <div class=\"split-screen__half\">\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/stacked-cards.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-25'\ndescription: Create stacked cards with CSS\nkeywords: css card, css stacked cards, css transform rotate\nthumbnail: /assets/css-layout/thumbnails/stacked-cards.png\ntitle: Stacked cards\n---\n\n## HTML\n\n```html index.html\n<div class=\"stacked-cards\">\n    <!-- Repeat if you want to have more cards -->\n    <div class=\"stacked-cards__card\"></div>\n\n    <!-- Main card's content -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.stacked-cards {\n    /* Used to position the stacked cards */\n    position: relative;\n\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n}\n\n.stacked-cards__card {\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Displayed under the container */\n    z-index: 1;\n\n    /* Background and border colors */\n    background-color: rgb(255, 255, 255);\n    border: 1px solid #d1d5db;\n\n    /* Rotate it. Change the number of degrees for the following cards */\n    transform: rotate(5deg);\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.stacked-cards {\n    /* Used to position the stacked cards */\n    position: relative;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 16rem;\n    width: 16rem;\n}\n\n.stacked-cards__card {\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Displayed under the container */\n    z-index: 1;\n\n    /* Background and border colors */\n    background-color: rgb(255, 255, 255);\n    border: 1px solid #d1d5db;\n}\n.stacked-cards__card--1st {\n    /* Rotate it. Change the number of degrees for the following cards */\n    transform: rotate(5deg);\n}\n.stacked-cards__card--2nd {\n    /* Rotate it. Change the number of degrees for the following cards */\n    transform: rotate(10deg);\n}\n.stacked-cards__card--3rd {\n    /* Rotate it. Change the number of degrees for the following cards */\n    transform: rotate(15deg);\n}\n```\n\n```html index.html hidden\n<div class=\"stacked-cards\">\n    <div class=\"stacked-cards__card stacked-cards__card--1st\"></div>\n    <div class=\"stacked-cards__card stacked-cards__card--2nd\"></div>\n    <div class=\"stacked-cards__card stacked-cards__card--3rd\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/stamp-border.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-16'\ndescription: Create stamp border with CSS\nkeywords: css radial gradient, css stamp border\nthumbnail: /assets/css-layout/thumbnails/stamp-border.png\ntitle: Stamp border\n---\n\n## HTML\n\n```html index.html\n<div class=\"stamp-border\">\n    <div class=\"stamp-border__content\"></div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.stamp-border {\n    /* Background */\n    background-color: #d1d5db;\n    background-image: radial-gradient(#fff 50%, transparent 50%);\n    background-position: -0.25rem -0.25rem;\n    background-repeat: repeat;\n    background-size: 0.5rem 0.5rem;\n\n    /* Spacing */\n    padding: 0.25rem;\n}\n\n.stamp-border__content {\n    /* Background */\n    background-color: #d1d5db;\n\n    height: 100%;\n    width: 100%;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.stamp-border {\n    /* Background */\n    background-color: #d1d5db;\n    background-image: radial-gradient(#fff 50%, transparent 50%);\n    background-position: -0.25rem -0.25rem;\n    background-repeat: repeat;\n    background-size: 0.5rem 0.5rem;\n\n    /* Spacing */\n    padding: 0.25rem;\n\n    /* Demo */\n    height: 100%;\n    width: 100%;\n}\n\n.stamp-border__content {\n    /* Background */\n    background-color: #d1d5db;\n\n    height: 100%;\n    width: 100%;\n}\n```\n\n```html index.html hidden\n<div class=\"stamp-border\">\n    <div class=\"stamp-border__content\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/statistic.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-30'\ndescription: Create a statistic component with CSS flexbox\nkeywords: css flexbox, css statistic\nthumbnail: /assets/css-layout/thumbnails/statistic.png\ntitle: Statistic\n---\n\n## HTML\n\n```html index.html\n<div class=\"statistic\">\n    <!-- Value -->\n    <div class=\"statistic__value\">...</div>\n\n    <!-- Label -->\n    <div class=\"statistic__label\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.statistic {\n    /* Center the content */\n    align-items: center;\n    display: inline-flex;\n    flex-direction: column;\n}\n\n.statistic__value {\n    /* Big font size */\n    font-size: 4rem;\n    font-weight: 500;\n}\n\n.statistic__label {\n    /* Smaller font size */\n    font-size: 1rem;\n    font-weight: 700;\n\n    /* Uppercase the label */\n    text-transform: uppercase;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.statistic {\n    /* Center the content */\n    align-items: center;\n    display: inline-flex;\n    flex-direction: column;\n}\n\n.statistic__value {\n    /* Big font size */\n    font-size: 3rem;\n    font-weight: 500;\n}\n\n.statistic__label {\n    /* Smaller font size */\n    font-size: 1rem;\n    font-weight: 700;\n\n    /* Uppercase the label */\n    text-transform: uppercase;\n}\n```\n\n```html index.html hidden\n<div class=\"statistic\">\n    <div class=\"statistic__value\">\n        9k+\n    </div>\n    <div class=\"statistic__label\">\n        stars\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/status-light.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-12'\ndescription: Create a status light with CSS flexbox\nkeywords: css flexbox, css status light\nthumbnail: /assets/css-layout/thumbnails/status-light.png\ntitle: Status light\n---\n\n## HTML\n\n```html index.html\n<div class=\"status-light\">\n    <!-- Status light -->\n    <div class=\"status-light__status\"></div>\n\n    <!-- Content -->\n    <div class=\"status-light__content\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.status-light {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n}\n\n.status-light__status {\n    /* Background color */\n    background-color: #16a34a;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    height: 0.5rem;\n    width: 0.5rem;\n\n    /* Spacing */\n    margin-right: 0.5rem;\n}\n\n.status-light__content {\n    /* Take available width */\n    flex: 1;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.status-light {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n\n    /* Demo */\n    width: 8rem;\n}\n\n.status-light__status {\n    /* Background color */\n    background-color: #16a34a;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    height: 0.5rem;\n    width: 0.5rem;\n\n    /* Spacing */\n    margin-right: 0.5rem;\n}\n\n.status-light__content {\n    /* Take available width */\n    flex: 1;\n}\n```\n\n```html index.html hidden\n<div class=\"status-light\">\n    <div class=\"status-light__status\"></div>\n    <div class=\"status-light__content\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/stepper-input.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-16'\ndescription: Create a stepper input with CSS flexbox\nkeywords: css flexbox, css stepper input\nthumbnail: /assets/css-layout/thumbnails/stepper-input.png\ntitle: Stepper input\n---\n\n## HTML\n\n```html index.html\n<div class=\"stepper-input\">\n    <!-- Minus button -->\n    <button class=\"stepper-input__button\">-</button>\n\n    <!-- Input container -->\n    <div class=\"stepper-input__content\">\n        <input type=\"text\" class=\"stepper-input__input\" />\n    </div>\n\n    <!-- Plus button -->\n    <button class=\"stepper-input__button\">+</button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.stepper-input {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Size */\n    height: 2rem;\n}\n\n.stepper-input__button {\n    /* Reset */\n    background: #d1d5db;\n    border: none;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    width: 2rem;\n}\n\n.stepper-input__content {\n    flex: 1;\n}\n\n.stepper-input__input {\n    /* Reset */\n    border: none;\n\n    /* Take full size of its container */\n    height: 100%;\n    width: 100%;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.stepper-input {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Size */\n    height: 2rem;\n    width: 16rem;\n}\n\n.stepper-input__button {\n    /* Reset */\n    background: #d1d5db;\n    border: none;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    width: 2rem;\n}\n\n.stepper-input__content {\n    flex: 1;\n}\n\n.stepper-input__input {\n    /* Reset */\n    border: none;\n\n    /* Take full size of its container */\n    height: 100%;\n    width: 100%;\n}\n```\n\n```html index.html hidden\n<div class=\"stepper-input\">\n    <button class=\"stepper-input__button\">-</button>\n    <div class=\"stepper-input__content\">\n        <input type=\"text\" class=\"stepper-input__input\" />\n    </div>\n    <button class=\"stepper-input__button\">+</button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/sticky-footer.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-15'\ndescription: Create a sticky footer with CSS flexbox\nkeywords: css flexbox, css layout, css sticky, css sticky footer\nthumbnail: /assets/css-layout/thumbnails/sticky-footer.png\ntitle: Sticky footer\n---\n\n## HTML\n\n```html index.html\n<div class=\"sticky-footer\">\n    <header class=\"sticky-footer__header\">...</header>\n    <main class=\"sticky-footer__main\">...</main>\n    <footer class=\"sticky-footer__footer\">...</footer>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.sticky-footer {\n    display: flex;\n    flex-direction: column;\n    height: 100%;\n}\n\n.sticky-footer__header,\n.sticky-footer__footer {\n    flex-shrink: 0;\n}\n\n.sticky-footer__main {\n    flex-grow: 1;\n}\n```\n\nThe footer always sticks to the bottom if the main content is short.\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.sticky-footer {\n    display: flex;\n    flex-direction: column;\n    height: 100%;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    width: 100%;\n}\n\n.sticky-footer__header,\n.sticky-footer__footer {\n    flex-shrink: 0;\n\n    /* Demo */\n    padding: 0.25rem;\n}\n\n.sticky-footer__main {\n    flex-grow: 1;\n\n    /* Demo */\n    border-top: 1px solid #d1d5db;\n    border-bottom: 1px solid #d1d5db;\n    padding: 0.25rem;\n}\n```\n\n```html index.html hidden\n<div class=\"sticky-footer\">\n    <div class=\"sticky-footer__header\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n    <div class=\"sticky-footer__main\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"sticky-footer__footer\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/sticky-header.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-11-15'\ndescription: Create a sticky header with CSS\nkeywords: css layout, css position sticky, css sticky header\nthumbnail: /assets/css-layout/thumbnails/sticky-header.png\ntitle: Sticky header\n---\n\n## HTML\n\n```html index.html\n<div>\n    <header class=\"sticky-header__header\">...</header>\n    <main>...</main>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.sticky-header__header {\n    /* Stick to the top */\n    position: sticky;\n    top: 0;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.sticky-header {\n    /* Demo */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    height: 100%;\n    width: 100%;\n}\n\n.sticky-header__header {\n    /* Stick to the top */\n    position: sticky;\n    top: 0;\n\n    /* Demo */\n    padding: 0.25rem;\n    border-bottom: 1px solid #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"sticky-header\">\n    <div class=\"sticky-header__header\">\n        <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n    </div>\n    <div class=\"lines\">\n        <div class=\"line line--20\"></div>\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n        <div class=\"line line--60\"></div>\n        <div class=\"line line--20\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/sticky-sections.mdx",
    "content": "---\ncategory: Layout\ncreated: '2019-12-19'\ndescription: Create sticky sections with CSS\nkeywords: css layout, css sticky, css sticky sections\nthumbnail: /assets/css-layout/thumbnails/sticky-sections.png\ntitle: Sticky sections\n---\n\n## HTML\n\n```html index.html\n<div class=\"sticky-sections\">\n    <section class=\"sticky-sections__section\">...</section>\n\n    <!-- Repeat other sections -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.sticky-sections {\n    height: 100%;\n    overflow: scroll;\n}\n\n.sticky-sections__section {\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Stick to the top */\n    position: sticky;\n    top: 0;\n}\n```\n\n<Playground>\n```css styles.css hidden\n.sticky-sections {\n    height: 24rem;\n\n    /* Demo */\n    width: 100%;\n}\n\n.sticky-sections__section {\n    /* Take full size */\n    height: 25%;\n    width: 100%;\n\n    /* Stick to the top */\n    position: sticky;\n    top: 0;\n}\n\n/* Demo */\n.sticky-sections__section:nth-child(1) {\n    background-color: #e5e7eb;\n}\n.sticky-sections__section:nth-child(2) {\n    background-color: #d1d5db;\n}\n.sticky-sections__section:nth-child(3) {\n    background-color: #9ca3af;\n}\n.sticky-sections__section:nth-child(4) {\n    background-color: #6b7280;\n}\n```\n\n```html index.html hidden\n<div class=\"sticky-sections\">\n    <section class=\"sticky-sections__section\"></section>\n    <section class=\"sticky-sections__section\"></section>\n    <section class=\"sticky-sections__section\"></section>\n    <section class=\"sticky-sections__section\"></section>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/sticky-table-column.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-29'\ndescription: Create sticky table column with CSS\nkeywords: css position sticky, css sticky table column\nthumbnail: /assets/css-layout/thumbnails/sticky-table-column.png\ntitle: Sticky table column\n---\n\n## HTML\n\n```html index.html\n<table class=\"sticky-table-column\">\n    <thead>\n        <tr>\n            <th class=\"sticky-table-column__sticky\">...</th>\n\n            <!-- Other header column ... -->\n        </tr>\n    </thead>\n    <tbody>\n        <tr>\n            <td class=\"sticky-table-column__sticky\">...</td>\n            <!-- Other columns ... -->\n        </tr>\n    </tbody>\n</table>\n```\n\n## CSS\n\n```css styles.css\n.sticky-table-headers__sticky {\n    /* Background color */\n    background-color: #9ca3af;\n\n    /* Stick to the left */\n    left: 0;\n    position: sticky;\n\n    /* Displayed on top of other rows when scrolling */\n    z-index: 9999;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.sticky-table-column {\n    /* Demo */\n    border-collapse: collapse;\n    width: 100%;\n}\n\n.sticky-table-column tbody {\n    border-bottom: 1px solid #d1d5db;\n}\n\n.sticky-table-column tr {\n    border-top: 1px solid #d1d5db;\n}\n\n.sticky-table-column__sticky {\n    /* Background color */\n    background-color: #9ca3af;\n\n    /* Stick to the left */\n    left: 0;\n    position: sticky;\n\n    /* Displayed on top of other rows when scrolling */\n    z-index: 9999;\n\n    padding: 0 0.25rem;\n}\n```\n\n```html index.html hidden\n<table class=\"sticky-table-column\">\n    <tbody>\n        <tr>\n            <td class=\"sticky-table-column__sticky\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n        </tr>\n\n        <tr>\n            <td class=\"sticky-table-column__sticky\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n        </tr>\n\n        <tr>\n            <td class=\"sticky-table-column__sticky\">\n                <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n        </tr>\n    </tbody>\n</table>\n```\n</Playground>\n"
  },
  {
    "path": "contents/sticky-table-headers.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-26'\ndescription: Create sticky table headers with CSS\nkeywords: css position sticky, css sticky table headers\nthumbnail: /assets/css-layout/thumbnails/sticky-table-headers.png\ntitle: Sticky table headers\n---\n\n## HTML\n\n```html index.html\n<table class=\"sticky-table-headers\">\n    <thead>\n        <tr class=\"sticky-table-headers__sticky\"></tr>\n    </thead>\n    <tbody>\n        ...\n    </tbody>\n</table>\n```\n\n## CSS\n\n```css styles.css\n.sticky-table-headers__sticky {\n    /* Background color */\n    background-color: #9ca3af;\n\n    /* Stick to the left */\n    left: 0;\n    position: sticky;\n\n    /* Displayed on top of other rows when scrolling */\n    z-index: 9999;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.sticky-table-headers {\n    /* Demo */\n    border-collapse: collapse;\n    width: 100%;\n}\n\n.sticky-table-headers tbody {\n    border-bottom: 1px solid #d1d5db;\n}\n.sticky-table-headers thead td {\n    padding: 0.25rem;\n}\n.sticky-table-headers tr {\n    border-top: 1px solid #d1d5db;\n}\n\n.sticky-table-headers__sticky {\n    /* Background color */\n    background-color: #9ca3af;\n\n    /* Stick to the left */\n    left: 0;\n    position: sticky;\n\n    /* Displayed on top of other rows when scrolling */\n    z-index: 9999;\n}\n```\n\n```html index.html hidden\n<table class=\"sticky-table-headers\">\n    <thead>\n        <tr class=\"sticky-table-headers__sticky\">\n            <td><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></td>\n            <td><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></td>\n            <td><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></td>\n        </tr>\n    </thead>\n    <tbody>\n        <tr>\n            <td><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n        </tr>\n\n        <tr>\n            <td><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n        </tr>\n\n        <tr>\n            <td><div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div></td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n            <td>\n                <div class=\"lines\">\n                    <div class=\"line line--20\"></div>\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </td>\n        </tr>\n    </tbody>\n</table>\n```\n</Playground>\n"
  },
  {
    "path": "contents/switch.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-17'\ndescription: Create a switch with CSS flexbox\nkeywords: css custom checkbox, css flexbox, css switch, css switcher\nthumbnail: /assets/css-layout/thumbnails/switch.png\ntitle: Switch\n---\n\nThe checkbox is placed inside a label. So when clicking on the label, the checkbox will be checked even though it's hidden.\n\n## HTML\n\n```html index.html\n<label class=\"switch switch--on\">\n    <input type=\"checkbox\" class=\"switch__input\" />\n\n    <!-- Circle -->\n    <div class=\"switch__circle\"></div>\n</label>\n\n<label class=\"switch switch--off\">\n    <input type=\"checkbox\" class=\"switch__input\" />\n\n    <!-- Circle -->\n    <div class=\"switch__circle\"></div>\n</label>\n```\n\n## CSS\n\n```css styles.css\n.switch {\n    display: flex;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    height: 2rem;\n    width: 4rem;\n\n    /* Demo */\n    margin-bottom: 0.5rem;\n}\n\n.switch__input {\n    /* Hide the input */\n    display: none;\n}\n\n.switch__circle {\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    width: 2rem;\n\n    background-color: #fff;\n}\n```\n\nThe switch comes with two variants:\n\n```css\n/* ON status */\n.switch--on {\n    background-color: #357edd;\n    border: 1px solid #357edd;\n\n    /* Push the circle to the right */\n    justify-content: flex-end;\n}\n\n/* OFF status */\n.switch--off {\n    background-color: #d1d5db;\n    border: 1px solid #d1d5db;\n}\n.switch--off .switch__circle {\n    border: 1px solid #d1d5db;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.switch {\n    display: flex;\n\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    height: 2rem;\n    width: 4rem;\n\n    /* Demo */\n    margin-bottom: 0.5rem;\n}\n\n.switch__input {\n    /* Hide the input */\n    display: none;\n}\n\n.switch__circle {\n    /* Rounded border */\n    border-radius: 9999px;\n\n    /* Size */\n    width: 2rem;\n\n    background-color: #fff;\n}\n\n/* ON status */\n.switch--on {\n    background-color: #357edd;\n    border: 1px solid #357edd;\n\n    /* Push the circle to the right */\n    justify-content: flex-end;\n}\n\n/* OFF status */\n.switch--off {\n    background-color: #d1d5db;\n    border: 1px solid #d1d5db;\n}\n.switch--off .switch__circle {\n    border: 1px solid #d1d5db;\n}\n```\n\n```html index.html hidden\n<label class=\"switch switch--off\">\n    <input type=\"checkbox\" class=\"switch__input\" />\n    <div class=\"switch__circle\"></div>\n</label>\n<label class=\"switch switch--on\">\n    <input type=\"checkbox\" class=\"switch__input\" />\n    <div class=\"switch__circle\"></div>\n</label>\n```\n</Playground>\n"
  },
  {
    "path": "contents/tab.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-22'\ndescription: Create tabs with CSS flexbox\nkeywords: css flexbox, css navigation, css tab\nthumbnail: /assets/css-layout/thumbnails/tab.png\ntitle: Tab\n---\n\n## HTML\n\n```html index.html\n<div class=\"tab\">\n    <!-- Active tab -->\n    <div class=\"tab__item tab__item--active\">...</div>\n\n    <!-- Inactive tab -->\n    <div class=\"tab__item tab__item--inactive\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.tab {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.tab__item {\n    border-top-left-radius: 0.25rem;\n    border-top-right-radius: 0.25rem;\n    padding: 0.5rem 1rem;\n}\n\n.tab__item--active {\n    /* Border */\n    border: 1px solid #d1d5db;\n    /* Hide the bottom border */\n    border-bottom-color: transparent;\n\n    /* Border radius */\n    border-top-left-radius: 2px;\n    border-top-right-radius: 2px;\n}\n\n.tab__item--inactive {\n    /* Has only the bottom border */\n    border-bottom: 1px solid #d1d5db;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.circle {\n    background: #d1d5db;\n    border-radius: 9999px;\n    height: var(--circle-size);\n    width: var(--circle-size);\n}\n.circle--sm {\n    --circle-size: 0.5rem;\n}\n.circle--md {\n    --circle-size: 1.5rem;\n}\n.circle--lg {\n    --circle-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.tab {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.tab__item {\n    border-top-left-radius: 0.25rem;\n    border-top-right-radius: 0.25rem;\n    padding: 0.5rem 1rem;\n}\n\n.tab__item--active {\n    /* Border */\n    border: 1px solid #d1d5db;\n    /* Hide the bottom border */\n    border-bottom-color: transparent;\n\n    /* Border radius */\n    border-top-left-radius: 2px;\n    border-top-right-radius: 2px;\n}\n\n.tab__item--inactive {\n    /* Has only the bottom border */\n    border-bottom: 1px solid #d1d5db;\n}\n```\n\n```html index.html hidden\n<div class=\"tab\">\n    <div class=\"tab__item tab__item--active\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n    <div class=\"tab__item tab__item--inactive\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n    <div class=\"tab__item tab__item--inactive\">\n        <div class=\"circle circle--sm\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/teardrop.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-30'\ndescription: Create a teardrop with CSS\nkeywords: css border radius, css teardrop, css water drop shape, css water droplet\nthumbnail: /assets/css-layout/thumbnails/teardrop.png\ntitle: Teardrop\n---\n\n## HTML\n\n```html index.html\n<div class=\"teardrop\">\n    <!-- Display the content vertically -->\n    <div class=\"teardrop__content\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.teardrop {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Border */\n    border: 2px solid #d1d5db;\n    border-radius: 0px 50% 50% 50%;\n\n    /* Angle at the top */\n    transform: rotate(45deg);\n\n    /* Size */\n    height: 4rem;\n    width: 4rem;\n}\n\n.teardrop__content {\n    transform: rotate(-45deg);\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.teardrop {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Border */\n    border: 2px solid #d1d5db;\n    border-radius: 0px 50% 50% 50%;\n\n    /* Angle at the top */\n    transform: rotate(45deg);\n\n    /* Size */\n    height: 4rem;\n    width: 4rem;\n}\n\n.teardrop__content {\n    transform: rotate(-45deg);\n}\n```\n\n```html index.html hidden\n<div class=\"teardrop\">\n    <div class=\"teardrop__content\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/three-dimensions-card.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-04'\ndescription: Create a 3D card with CSS\nkeywords: css 3D card\nthumbnail: /assets/css-layout/thumbnails/three-dimensions-card.png\ntitle: Three dimensions card\n---\n\n## HTML\n\n```html index.html\n<div class=\"three-dimensions-card\">...</div>\n```\n\n## CSS\n\n```css styles.css\n:root {\n    --three-dimensions-card-left-side-width: 1rem;\n}\n\n.three-dimensions-card {\n    position: relative;\n}\n\n/* The left side */\n.three-dimensions-card::before {\n    background: #d1d5db;\n    content: '';\n\n    /* Position */\n    top: var(--three-dimensions-card-left-side-width);\n    left: 0px;\n    position: absolute;\n    transform: translate(-100%, 0) skewY(-45deg);\n    transform-origin: left top;\n\n    /* Size */\n    height: 100%;\n    width: var(--three-dimensions-card-left-side-width);\n}\n\n/* The bottom side */\n.three-dimensions-card::after {\n    background: #d1d5db;\n    content: '';\n\n    /* Position */\n    bottom: 0px;\n    left: 0px;\n    position: absolute;\n    transform: translate(0, 100%) skewX(-45deg);\n    transform-origin: left top;\n\n    /* Size */\n    height: var(--three-dimensions-card-left-side-width);\n    width: 100%;\n}\n```\n\n<Playground>\n```css styles.css hidden\n:root {\n    --three-dimensions-card-left-side-width: 1rem;\n}\n\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.three-dimensions-card {\n    position: relative;\n\n    /* Demo */\n    border: 1px solid #d1d5db;\n    height: 6rem;\n    width: 6rem;\n}\n\n/* The left side */\n.three-dimensions-card::before {\n    background: #d1d5db;\n    content: '';\n\n    /* Position */\n    top: var(--three-dimensions-card-left-side-width);\n    left: 0px;\n    position: absolute;\n    transform: translate(-100%, 0) skewY(-45deg);\n    transform-origin: left top;\n\n    /* Size */\n    height: 100%;\n    width: var(--three-dimensions-card-left-side-width);\n}\n\n/* The bottom side */\n.three-dimensions-card::after {\n    background: #d1d5db;\n    content: '';\n\n    /* Position */\n    bottom: 0px;\n    left: 0px;\n    position: absolute;\n    transform: translate(0, 100%) skewX(-45deg);\n    transform-origin: left top;\n\n    /* Size */\n    height: var(--three-dimensions-card-left-side-width);\n    width: 100%;\n}\n```\n\n```html index.html hidden\n<div class=\"three-dimensions-card\"></div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/timeline.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-12'\ndescription: Create a timeline with CSS flexbox\nkeywords: css flexbox, css timeline\nthumbnail: /assets/css-layout/thumbnails/timeline.png\ntitle: Timeline\n---\n\n## HTML\n\n```html index.html\n<div class=\"timeline\">\n    <!-- Left vertical line -->\n    <div class=\"timeline__line\"></div>\n\n    <!-- The timeline items timeline -->\n    <div class=\"timeline__items\">\n        <!-- Each timeline item -->\n        <div class=\"timeline__item\">\n            <!-- The circle and title -->\n            <div class=\"timeline__top\">\n                <!-- The circle -->\n                <div class=\"timeline__circle\"></div>\n\n                <!-- The title -->\n                <div class=\"timeline__title\">...</div>\n            </div>\n\n            <!-- The description -->\n            <div class=\"timeline__desc\">...</div>\n        </div>\n\n        <!-- Repeat other items -->\n        ...\n    </div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.timeline {\n    /* Used to position the left vertical line */\n    position: relative;\n}\n\n.timeline__line {\n    /* Border */\n    border-right: 2px solid #d1d5db;\n\n    /* Positioned at the left */\n    left: 0.75rem;\n    position: absolute;\n    top: 0px;\n\n    /* Take full height */\n    height: 100%;\n}\n\n.timeline__items {\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0px;\n    padding: 0px;\n}\n\n.timeline__item {\n    margin-bottom: 8px;\n}\n\n.timeline__top {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n}\n\n.timeline__circle {\n    /* Rounded border */\n    background-color: #d1d5db;\n    border-radius: 9999px;\n\n    /* Size */\n    height: 1.5rem;\n    width: 1.5rem;\n}\n\n.timeline__title {\n    /* Take available width */\n    flex: 1;\n    margin-left: 0.5rem;\n}\n\n.timeline__desc {\n    /* Make it align with the title */\n    margin-left: 2rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n.rectangle {\n    background: #d1d5db;\n    border-radius: 0.25rem;\n    height: var(--rectangle-height);\n    width: var(--rectangle-width);\n}\n.rectangle--hor.rectangle--20 {\n    --rectangle-width: 20%;\n}\n.rectangle--hor.rectangle--40 {\n    --rectangle-width: 40%;\n}\n.rectangle--hor.rectangle--60 {\n    --rectangle-width: 60%;\n}\n.rectangle--hor.rectangle--80 {\n    --rectangle-width: 80%;\n}\n.rectangle--hor.rectangle--100 {\n    --rectangle-width: 100%;\n}\n.rectangle--hor.rectangle--sm {\n    --rectangle-height: 0.5rem;\n}\n.rectangle--hor.rectangle--md {\n    --rectangle-height: 2rem;\n}\n.rectangle--hor.rectangle--lg {\n    --rectangle-height: 4rem;\n}\n.rectangle--ver.rectangle--20 {\n    --rectangle-height: 20%;\n}\n.rectangle--ver.rectangle--40 {\n    --rectangle-height: 40%;\n}\n.rectangle--ver.rectangle--60 {\n    --rectangle-height: 60%;\n}\n.rectangle--ver.rectangle--80 {\n    --rectangle-height: 80%;\n}\n.rectangle--ver.rectangle--100 {\n    --rectangle-height: 100%;\n}\n.rectangle--ver.rectangle--sm {\n    --rectangle-width: 0.5rem;\n}\n.rectangle--ver.rectangle--md {\n    --rectangle-width: 2rem;\n}\n.rectangle--ver.rectangle--lg {\n    --rectangle-width: 4rem;\n}\n```\n\n```css styles.css hidden\n.timeline {\n    /* Used to position the left vertical line */\n    position: relative;\n\n    /* Demo */\n    height: 100%;\n    width: 100%;\n}\n\n.timeline__line {\n    /* Border */\n    border-right: 2px solid #d1d5db;\n\n    /* Positioned at the left */\n    left: 0.75rem;\n    position: absolute;\n    top: 0px;\n\n    /* Take full height */\n    height: 100%;\n}\n\n.timeline__items {\n    /* Reset styles */\n    list-style-type: none;\n    margin: 0px;\n    padding: 0px;\n}\n\n.timeline__item {\n    margin-bottom: 8px;\n}\n\n.timeline__top {\n    /* Center the content horizontally */\n    align-items: center;\n    display: flex;\n}\n\n.timeline__circle {\n    /* Rounded border */\n    background-color: #d1d5db;\n    border-radius: 9999px;\n\n    /* Size */\n    height: 1.5rem;\n    width: 1.5rem;\n}\n\n.timeline__title {\n    /* Take available width */\n    flex: 1;\n    margin-left: 0.5rem;\n}\n\n.timeline__desc {\n    /* Make it align with the title */\n    margin-left: 2rem;\n}\n```\n\n```html index.html hidden\n<div class=\"timeline\">\n    <div class=\"timeline__line\"></div>\n    <div class=\"timeline__items\">\n        <div class=\"timeline__item\">\n            <div class=\"timeline__top\">\n                <div class=\"timeline__circle\"></div>\n                <div class=\"timeline__title\">\n                    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n                </div>\n            </div>\n            <div class=\"timeline__desc\">\n                <div class=\"lines\">\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--100\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </div>\n        </div>\n\n        <div class=\"timeline__item\">\n            <div class=\"timeline__top\">\n                <div class=\"timeline__circle\"></div>\n                <div class=\"timeline__title\">\n                    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n                </div>\n            </div>\n            <div class=\"timeline__desc\">\n                <div class=\"lines\">\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--100\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </div>\n        </div>\n\n        <div class=\"timeline__item\">\n            <div class=\"timeline__top\">\n                <div class=\"timeline__circle\"></div>\n                <div class=\"timeline__title\">\n                    <div class=\"rectangle rectangle--hor rectangle--sm rectangle--100\"></div>\n                </div>\n            </div>\n            <div class=\"timeline__desc\">\n                <div class=\"lines\">\n                    <div class=\"line line--80\"></div>\n                    <div class=\"line line--40\"></div>\n                    <div class=\"line line--100\"></div>\n                    <div class=\"line line--60\"></div>\n                    <div class=\"line line--20\"></div>\n                </div>\n            </div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/toggle-password-visibility.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-23'\ndescription: Create a toggle password visibility with CSS flexbox\nkeywords: css flexbox, toggle password visibility\nthumbnail: /assets/css-layout/thumbnails/toggle-password-visibility.png\ntitle: Toggle password visibility\n---\n\n## HTML\n\n```html index.html\n<div class=\"toggle-password-visibility\">\n    <!-- Text input -->\n    <input type=\"text\" class=\"toggle-password-visibility__input\" />\n\n    <!-- Toggle button sticks to the right -->\n    <button class=\"toggle-password-visibility__toggle\">...</button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.toggle-password-visibility {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem;\n}\n\n.toggle-password-visibility__input {\n    border-color: transparent;\n\n    /* Take available width */\n    flex: 1;\n}\n\n.toggle-password-visibility__toggle {\n    /* Reset */\n    background: #fff;\n    border-color: transparent;\n\n    /* Center the content */\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n```\n\nIn reality, the `click` event handler of the button needs to update the `type` attribute of the input to `text` or `password`:\n\n```js\ndocument.querySelector('.toggle-password-visibility__toggle').addEventListener('click', (e) => {\n    const input = e.target.previousElementSibling;\n    const type = input.getAttribute('type');\n    input.setAttribute('type', type === 'text' ? 'password' : 'text');\n});\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.toggle-password-visibility {\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem;\n\n    /* Demo */\n    height: 2.5rem;\n}\n\n.toggle-password-visibility__input {\n    border-color: transparent;\n    /* Take available width */\n    flex: 1;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.toggle-password-visibility__toggle {\n    /* Reset */\n    background: #fff;\n    border-color: transparent;\n\n    /* Center the content */\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n\n.toggle-password-visibility__svg {\n    fill: none;\n    height: 1.5rem;\n    stroke: #d1d5db;\n    stroke-linecap: round;\n    stroke-linejoin: round;\n    stroke-width: 1;\n    width: 1.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"toggle-password-visibility\">\n    <input type=\"text\" class=\"toggle-password-visibility__input\" value=\"*****\" />\n    <button class=\"toggle-password-visibility__toggle\">\n        <svg class=\"toggle-password-visibility__svg\" viewBox=\"0 0 24 24\">\n            <path d=\"M23.5,12c0,0-5.148,6.5-11.5,6.5S0.5,12,0.5,12S5.648,5.5,12,5.5S23.5,12,23.5,12z M12,8c2.209,0,4,1.791,4,4 s-1.791,4-4,4s-4-1.791-4-4S9.791,8,12,8z M12,10c1.105,0,2,0.895,2,2s-0.895,2-2,2s-2-0.895-2-2\"></path>\n        </svg>\n    </button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/tooltip.mdx",
    "content": "---\ncategory: Feedback\ncontributors:\n    - arthur322\ncreated: '2019-12-18'\ndescription: Create a tooltip with CSS\nkeywords: css tooltip\nthumbnail: /assets/css-layout/thumbnails/tooltip.png\ntitle: Tooltip\nupdated: '2021-10-01'\n---\n\n## HTML\n\n```html index.html\n<div class=\"tooltip\">\n    <!-- The tooltip content -->\n    <div class=\"tooltip__content\">...</div>\n\n    <!-- The tooltip arrow -->\n    <div class=\"tooltip__arrow\"></div>\n\n    <!-- The trigger element -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.tooltip {\n    /* Used to position the arrow */\n    position: relative;\n}\n\n/* Show the arrow and content and restore pointer events when hovering the trigger element */\n.tooltip:hover .tooltip__arrow,\n.tooltip:hover .tooltip__content {\n    opacity: 1;\n    pointer-events: initial;\n}\n\n.tooltip__arrow {\n    /* Invisible by default */\n    opacity: 0;\n\n    /* To prevent accidental interactions with other elements  */\n    pointer-events: none;\n\n    /* Border */\n    border: 0.5rem solid transparent;\n    border-top-color: #111827;\n\n    /* Position */\n    bottom: 100%;\n    left: 50%;\n    position: absolute;\n    transform: translate(-50%, 8px);\n\n    /* Zero size */\n    height: 0;\n    width: 0;\n\n    /* Displayed on top of other element */\n    z-index: 10;\n}\n\n.tooltip__content {\n    /* Invisible by default */\n    opacity: 0;\n\n    /* To prevent accidental interactions with other elements  */\n    pointer-events: none;\n\n    /* Background color, must be the same as the border color of arrow */\n    background-color: #111827;\n    border-radius: 0.25rem;\n\n    /* Position */\n    bottom: 100%;\n    left: 50%;\n    position: absolute;\n    transform: translate(-50%, -8px);\n\n    /* Displayed on top of other element */\n    z-index: 10;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.tooltip {\n    /* Used to position the arrow */\n    position: relative;\n\n    /* Demo */\n    width: 8rem;\n    height: 2rem;\n    border-radius: 0.25rem;\n    background: #d1d5db;\n}\n\n/* Show the arrow and content and restore pointer events when hovering the trigger element */\n.tooltip:hover .tooltip__arrow,\n.tooltip:hover .tooltip__content {\n    opacity: 1;\n    pointer-events: initial;\n}\n\n.tooltip__arrow {\n    /* Invisible by default */\n    opacity: 1;\n\n    /* To prevent accidental interactions with other elements  */\n    pointer-events: none;\n\n    /* Border */\n    border: 0.5rem solid transparent;\n    border-top-color: #111827;\n\n    /* Position */\n    bottom: 100%;\n    left: 50%;\n    position: absolute;\n    transform: translate(-50%, 8px);\n\n    /* Zero size */\n    height: 0;\n    width: 0;\n\n    /* Displayed on top of other element */\n    z-index: 10;\n}\n\n.tooltip__content {\n    /* Invisible by default */\n    opacity: 1;\n\n    /* To prevent accidental interactions with other elements  */\n    pointer-events: none;\n\n    /* Background color, must be the same as the border color of arrow */\n    background-color: #111827;\n    border-radius: 0.25rem;\n\n    /* Position */\n    bottom: 100%;\n    left: 50%;\n    position: absolute;\n    transform: translate(-50%, -8px);\n\n    /* Displayed on top of other element */\n    z-index: 10;\n\n    /* Demo */\n    width: 6rem;\n}\n```\n\n```html index.html hidden\n<div class=\"tooltip\">\n    <div class=\"tooltip__content\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n    <div class=\"tooltip__arrow\"></div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/tree-diagram.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-03'\ndescription: Create a tree diagram with CSS\nkeywords: css sitemap, css tree diagram\nthumbnail: /assets/css-layout/thumbnails/tree-diagram.png\ntitle: Tree diagram\n---\n\n## HTML\n\n```html index.html\n<div class=\"tree-diagram\">\n    <ul>\n        <li>\n            <!-- Content -->\n            ...\n\n            <!-- Sub items -->\n            <ul>\n                <li>\n                    <!-- Content -->\n                    ...\n\n                    <!-- Sub items -->\n                    <ul>\n                        <li>...</li>\n                        <li>...</li>\n                        ...\n                    </ul>\n                </li>\n                <li>...</li>\n                ...\n            </ul>\n        </li>\n\n        <!-- Repeat other items -->\n        ...\n    </ul>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.tree-diagram ul {\n    display: flex;\n    position: relative;\n\n    /* Reset */\n    list-style-type: none;\n    margin: 0;\n    padding: 1rem 0.5rem 0rem 0.5rem;\n}\n\n.tree-diagram ul ul::before {\n    border-right: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    position: absolute;\n    top: 0;\n    right: 50%;\n\n    /* Size */\n    height: 1rem;\n    width: 50%;\n}\n\n.tree-diagram li {\n    padding: 1rem 0.5rem 0rem 0.5rem;\n    position: relative;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n}\n\n.tree-diagram li::before {\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    position: absolute;\n    top: 0;\n    right: 50%;\n\n    /* Size */\n    height: 1rem;\n    width: 50%;\n}\n\n.tree-diagram li::after {\n    border-top: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    position: absolute;\n    top: 0;\n    right: 0;\n\n    /* Size */\n    width: 50%;\n}\n\n.tree-diagram li:first-child::before,\n.tree-diagram li:last-child::after {\n    /* Remove the top of border from the first and last items */\n    border-top: none;\n}\n\n/* Add a root item if you want */\nli.tree-diagram__root::before {\n    border-right: none;\n}\n```\n\nYou can add a root item to the tree:\n\n```html\n<div class=\"tree-diagram\">\n    <ul>\n        <li class=\"tree-diagram__root\">...</li>\n    </ul>\n</div>\n```\n\n<Playground>\n```css placeholders.css hidden\n.square {\n    background: #d1d5db;\n    height: var(--square-size);\n    width: var(--square-size);\n}\n.square--sm {\n    --square-size: 0.5rem;\n}\n.square--md {\n    --square-size: 2rem;\n}\n.square--lg {\n    --square-size: 4rem;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.tree-diagram ul {\n    display: flex;\n    position: relative;\n\n    /* Reset */\n    list-style-type: none;\n    margin: 0;\n    padding: 1rem 0.5rem 0rem 0.5rem;\n}\n\n.tree-diagram ul ul::before {\n    border-right: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    position: absolute;\n    top: 0;\n    right: 50%;\n\n    /* Size */\n    height: 1rem;\n    width: 50%;\n}\n\n.tree-diagram li {\n    padding: 1rem 0.5rem 0rem 0.5rem;\n    position: relative;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n}\n\n.tree-diagram li::before {\n    border-right: 1px solid #d1d5db;\n    border-top: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    position: absolute;\n    top: 0;\n    right: 50%;\n\n    /* Size */\n    height: 1rem;\n    width: 50%;\n}\n\n.tree-diagram li::after {\n    border-top: 1px solid #d1d5db;\n    content: '';\n\n    /* Position */\n    position: absolute;\n    top: 0;\n    right: 0;\n\n    /* Size */\n    width: 50%;\n}\n\n.tree-diagram li:first-child::before,\n.tree-diagram li:last-child::after {\n    /* Remove the top of border from the first and last items */\n    border-top: none;\n}\n\n/* Add a root item if you want */\nli.tree-diagram__root::before {\n    border-right: none;\n}\n```\n\n```html index.html hidden\n<div class=\"tree-diagram\">\n    <ul>\n        <li class=\"tree-diagram__root\">\n            <div class=\"square square--sm\"></div>\n            <ul>\n                <li>\n                    <div class=\"square square--sm\"></div>\n                    <ul>\n                        <li>\n                            <div class=\"square square--sm\"></div>\n                        </li>\n                    </ul>\n                </li>\n                <li>\n                    <div class=\"square square--sm\"></div>\n                    <ul>\n                        <li>\n                            <div class=\"square square--sm\"></div>\n                        </li>\n                        <li>\n                            <div class=\"square square--sm\"></div>\n                        </li>\n                    </ul>\n                </li>\n            </ul>\n        </li>\n    </ul>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/triangle-buttons.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-21'\ndescription: Create triangle buttons with CSS\nkeywords: css triangle buttons\nthumbnail: /assets/css-layout/thumbnails/triangle-buttons.png\ntitle: Triangle buttons\n---\n\n## HTML\n\n```html index.html\n<!-- Up triangle button -->\n<button class=\"triangle-buttons\">\n    <!-- Triangle -->\n    <div class=\"triangle-buttons__triangle triangle-buttons__triangle--t\"></div>\n\n    <!-- Content -->\n    ...\n</button>\n\n<!-- Right triangle button -->\n<button class=\"triangle-buttons\">\n    <!-- Content -->\n    ...\n\n    <!-- Triangle -->\n    <div class=\"triangle-buttons__triangle triangle-buttons__triangle--r\"></div>\n</button>\n\n<!-- Down triangle button -->\n<button class=\"triangle-buttons\">\n    <!-- Triangle -->\n    <div class=\"triangle-buttons__triangle triangle-buttons__triangle--b\"></div>\n\n    <!-- Content -->\n    ...\n</button>\n\n<!-- Left triangle button -->\n<button class=\"triangle-buttons\">\n    <!-- Triangle -->\n    <div class=\"triangle-buttons__triangle triangle-buttons__triangle--l\"></div>\n\n    <!-- Content -->\n    ...\n</button>\n```\n\n## CSS\n\n```css styles.css\n.triangle-buttons {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Spacing */\n    padding: 0.5rem;\n}\n\n.triangle-buttons__triangle {\n    border-style: solid;\n\n    /* Size */\n    height: 0px;\n    width: 0px;\n}\n\n.triangle-buttons__triangle--t {\n    border-color: transparent transparent #d1d5db;\n    border-width: 0 0.5rem 0.5rem;\n}\n\n.triangle-buttons__triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: 0.5rem 0 0.5rem 0.5rem;\n}\n\n.triangle-buttons__triangle--b {\n    border-color: #d1d5db transparent transparent;\n    border-width: 0.5rem 0.5rem 0;\n}\n\n.triangle-buttons__triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0.5rem 0.5rem 0.5rem 0;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n.triangle-buttons__triangle {\n    border-style: solid;\n\n    /* Size */\n    height: 0;\n    width: 0;\n}\n\n.triangle-buttons__triangle--t {\n    border-color: transparent transparent #d1d5db;\n    border-width: 0 0.5rem 0.5rem;\n}\n\n.triangle-buttons__triangle--r {\n    border-color: transparent transparent transparent #d1d5db;\n    border-width: 0.5rem 0 0.5rem 0.5rem;\n}\n\n.triangle-buttons__triangle--b {\n    border-color: #d1d5db transparent transparent;\n    border-width: 0.5rem 0.5rem 0;\n}\n\n.triangle-buttons__triangle--l {\n    border-color: transparent #d1d5db transparent transparent;\n    border-width: 0.5rem 0.5rem 0.5rem 0;\n}\n\n/* Demo */\n.triangle-buttons {\n    position: relative;\n    height: 100%;\n    width: 100%;\n}\n.triangle-buttons__corner {\n    position: absolute;\n}\n.triangle-buttons__corner--t {\n    left: 50%;\n    top: 0;\n    transform: translate(-50%, 0%);\n}\n.triangle-buttons__corner--r {\n    right: 0;\n    top: 50%;\n    transform: translate(0%, -50%);\n}\n.triangle-buttons__corner--b {\n    bottom: 0;\n    left: 50%;\n    transform: translate(-50%, 0%);\n}\n.triangle-buttons__corner--l {\n    left: 0;\n    top: 50%;\n    transform: translate(0%, -50%);\n}\n```\n\n```html index.html hidden\n<div class=\"triangle-buttons\">\n    <div class=\"triangle-buttons__corner triangle-buttons__corner--t\">\n        <div class=\"triangle-buttons__triangle triangle-buttons__triangle--t\"></div>\n    </div>\n    <div class=\"triangle-buttons__corner triangle-buttons__corner--r\">\n        <div class=\"triangle-buttons__triangle triangle-buttons__triangle--r\"></div>\n    </div>\n    <div class=\"triangle-buttons__corner triangle-buttons__corner--b\">\n        <div class=\"triangle-buttons__triangle triangle-buttons__triangle--b\"></div>\n    </div>\n    <div class=\"triangle-buttons__corner triangle-buttons__corner--l\">\n        <div class=\"triangle-buttons__triangle triangle-buttons__triangle--l\"></div>\n    </div>\n</div>\n```\n</Playground>\n\n## See also\n\n-   [Carousel slider](https://phuoc.ng/collection/css-layout/carousel-slider/)\n-   [Popover arrow](https://phuoc.ng/collection/css-layout/popover-arrow/)\n-   [Scroll down indicator](https://phuoc.ng/collection/css-animation/scroll-down-indicator/)\n-   [Speech bubble](https://phuoc.ng/collection/css-layout/speech-bubble/)\n"
  },
  {
    "path": "contents/upload-button.mdx",
    "content": "---\ncategory: Input\ncreated: '2019-11-29'\ndescription: Create an upload button with CSS flexbox\nkeywords: css file input, css flexbox, css upload button\nthumbnail: /assets/css-layout/thumbnails/upload-button.png\ntitle: Upload button\n---\n\n## HTML\n\n```html index.html\n<div class=\"upload-button\">\n    <!-- The real file input -->\n    <input type=\"file\" class=\"upload-button__input\" />\n\n    <!-- The upload icon -->\n    <div class=\"upload-button__icon\">...</div>\n\n    <!-- The label -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.upload-button {\n    /* Used to position the input */\n    position: relative;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem 0.5rem;\n}\n\n.upload-button__input {\n    /* Take the full size */\n    height: 100%;\n    left: 0;\n    position: absolute;\n    top: 0;\n    width: 100%;\n\n    /* Make it transparent */\n    opacity: 0;\n}\n\n.upload-button__icon {\n    margin-right: 0.5rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.upload-button {\n    /* Used to position the input */\n    position: relative;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    padding: 0.25rem 0.5rem;\n\n    /* Demo */\n    width: 8rem;\n}\n\n.upload-button__input {\n    /* Take the full size */\n    height: 100%;\n    left: 0;\n    position: absolute;\n    top: 0;\n    width: 100%;\n\n    /* Make it transparent */\n    opacity: 0;\n}\n\n.upload-button__icon {\n    margin-right: 0.5rem;\n}\n.upload-button__svg {\n    fill: none;\n    height: 1.5rem;\n    stroke: #d1d5db;\n    stroke-linecap: round;\n    stroke-linejoin: round;\n    stroke-width: 1;\n    width: 1.5rem;\n}\n```\n\n```html index.html hidden\n<div class=\"upload-button\">\n    <input type=\"file\" class=\"upload-button__input\" />\n    <div class=\"upload-button__icon\">\n        <svg class=\"upload-button__svg\" viewBox=\"0 0 24 24\">\n            <path d=\"M18.5,7.5c0.275,0,0.341-0.159,0.146-0.354l-6.292-6.292c-0.195-0.196-0.512-0.196-0.707-0.001 c0,0-0.001,0.001-0.001,0.001L5.354,7.147C5.154,7.342,5.225,7.501,5.5,7.501h3v10c0,0.552,0.448,1,1,1h5c0.552,0,1-0.448,1-1V7.5 H18.5z M23.5,18.5v4c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-4\"></path>\n        </svg>\n    </div>\n\n    <div class=\"lines\">\n        <div class=\"line line--20\"></div>\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/validation-icon.mdx",
    "content": "---\ncategory: Feedback\ncreated: '2019-12-12'\ndescription: Add validation icons to input with CSS\nkeywords: css validation icon\nthumbnail: /assets/css-layout/thumbnails/validation-icon.png\ntitle: Validation icon\n---\n\n## HTML\n\n```html index.html\n<div class=\"validation-icon\">\n    <!-- The input -->\n    <input class=\"validation-icon__input\" />\n\n    <!-- The icon validation-icon -->\n    <span class=\"validation-icon__icon\">\n        <!-- The SVG icon represents any state such as valid, invalid, loading, etc. -->\n        ...\n    </span>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.validation-icon {\n    /* Used to position the validation icon */\n    position: relative;\n}\n\n.validation-icon__input {\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Take the full width */\n    width: 100%;\n    height: 2rem;\n\n    /* Don't overlap the icon */\n    padding-right: 1.5rem;\n}\n\n.validation-icon__icon {\n    /* Positioned at the right side */\n    position: absolute;\n    right: 0.5rem;\n    top: 50%;\n    transform: translate(0, -50%);\n\n    z-index: 10;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.validation-icon {\n    /* Used to position the validation icon */\n    position: relative;\n\n    /* Demo */\n    width: 16rem;\n}\n\n.validation-icon__input {\n    /* Border */\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n\n    /* Take the full width */\n    width: 100%;\n    height: 2rem;\n\n    /* Don't overlap the icon */\n    padding-right: 1.5rem;\n}\n\n.validation-icon__icon {\n    /* Positioned at the right side */\n    position: absolute;\n    right: 0.5rem;\n    top: 50%;\n    transform: translate(0, -50%);\n\n    z-index: 10;\n}\n\n.validation-icon__svg {\n    fill: none;\n    height: 1rem;\n    width: 1rem;\n    stroke: #22c55e;\n    stroke-linecap: round;\n    stroke-linejoin: round;\n    stroke-width: 2;\n}\n```\n\n```html index.html hidden\n<div class=\"validation-icon\">\n    <input class=\"validation-icon__input\" />\n    <span class=\"validation-icon__icon\">\n        <svg class=\"validation-icon__svg\" viewBox=\"0 0 24 24\">\n            <path d=\"M23.5,0.499l-16.5,23l-6.5-6.5\"></path>\n        </svg>\n    </span>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/video-background.mdx",
    "content": "---\ncategory: Display\ncreated: '2019-12-16'\ndescription: Add video background with CSS flexbox\nkeywords: css flexbox, object fit cover\nthumbnail: /assets/css-layout/thumbnails/video-background.png\ntitle: Video background\n---\n\nIn this pattern, the video is displayed in the background.\n\n## HTML\n\n```html index.html\n<div class=\"video-background\">\n    <!-- The video container -->\n    <div class=\"video-background__inner\">\n        <video class=\"video-background__video\" src=\"...\">...</video>\n    </div>\n\n    <!-- The content -->\n    <div class=\"video-background__content\">...</div>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.video-background {\n    /* Used to position the video and content */\n    position: relative;\n}\n\n.video-background__inner {\n    /* Positioned at the top left corner */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Hide the scrollbar */\n    overflow: hidden;\n}\n\n.video-background__video {\n    object-fit: cover;\n\n    /* Take full width */\n    height: 100%;\n    max-width: 100%;\n}\n\n.video-background__content {\n    /* Positioned at the top left corner */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.video-background {\n    /* Used to position the video and content */\n    position: relative;\n\n    height: 100%;\n    width: 100%;\n}\n\n.video-background__inner {\n    /* Positioned at the top left corner */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Hide the scrollbar */\n    overflow: hidden;\n}\n\n.video-background__video {\n    object-fit: cover;\n\n    /* Take full width */\n    height: 100%;\n    max-width: 100%;\n}\n\n.video-background__content {\n    /* Positioned at the top left corner */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n}\n```\n\n```html index.html hidden\n<div class=\"video-background\">\n    <div class=\"video-background__inner\">\n        <video class=\"video-background__video\" src=\"/assets/css-layout/video-background.mp4\" autoplay loop muted></video>\n    </div>\n    <div class=\"video-background__content\">\n        <div class=\"lines\">\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--100\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/voting.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-01'\ndescription: Create a voting control with CSS flexbox\nkeywords: css flexbox, css triangle buttons, css voting control\nthumbnail: /assets/css-layout/thumbnails/voting.png\ntitle: Voting\n---\n\n## HTML\n\n```html index.html\n<div class=\"voting\">\n    <!-- Up button -->\n    <button class=\"voting__button\">\n        <div class=\"voting__triangle voting__triangle--up\"></div>\n    </button>\n\n    <!-- Number -->\n    <div class=\"voting__number\">...</div>\n\n    <!-- Down button -->\n    <button class=\"voting__button\">\n        <div class=\"voting__triangle voting__triangle--down\"></div>\n    </button>\n</div>\n```\n\n## CSS\n\n```css styles.css\n.voting {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    display: flex;\n    flex-direction: column;\n    height: 8rem;\n}\n\n.voting__button {\n    /* Reset */\n    background: none;\n    border: none;\n    cursor: pointer;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 1rem;\n\n    /* Position the triangle */\n    position: relative;\n}\n\n.voting__triangle {\n    border-style: solid;\n\n    /* Size */\n    height: 0;\n    width: 0;\n}\n\n.voting__triangle--up {\n    border-color: transparent transparent #d1d5db;\n    border-width: 0 0.5rem 0.5rem;\n}\n\n.voting__triangle--down {\n    border-color: #d1d5db transparent transparent;\n    border-width: 0.5rem 0.5rem 0px;\n}\n\n.voting__number {\n    /* Take the available height */\n    flex: 1;\n\n    /* Center the number */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Spacing */\n    padding: 0.25rem;\n}\n```\n\n<Playground>\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.voting {\n    border: 1px solid #d1d5db;\n    border-radius: 0.25rem;\n    display: flex;\n    flex-direction: column;\n    height: 8rem;\n}\n\n.voting__button {\n    /* Reset */\n    background: none;\n    border: none;\n    cursor: pointer;\n\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Size */\n    height: 1rem;\n\n    /* Position the triangle */\n    position: relative;\n}\n\n.voting__triangle {\n    border-style: solid;\n\n    /* Size */\n    height: 0;\n    width: 0;\n}\n\n.voting__triangle--up {\n    border-color: transparent transparent #d1d5db;\n    border-width: 0 0.5rem 0.5rem;\n}\n\n.voting__triangle--down {\n    border-color: #d1d5db transparent transparent;\n    border-width: 0.5rem 0.5rem 0px;\n}\n\n.voting__number {\n    /* Take the available height */\n    flex: 1;\n\n    /* Center the number */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Spacing */\n    padding: 0.25rem;\n}\n```\n\n```html index.html hidden\n<div class=\"voting\">\n    <button class=\"voting__button\">\n        <div class=\"voting__triangle voting__triangle--up\"></div>\n    </button>\n    <div class=\"voting__number\">999</div>\n    <button class=\"voting__button\">\n        <div class=\"voting__triangle voting__triangle--down\"></div>\n    </button>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/watermark.mdx",
    "content": "---\ncategory: Display\ncreated: '2020-01-18'\ndescription: Create a watermark with CSS\nkeywords: css watermark\nthumbnail: /assets/css-layout/thumbnails/watermark.png\ntitle: Watermark\n---\n\n## HTML\n\n```html index.html\n<div class=\"watermark\">\n    <!-- Watermark container -->\n    <div class=\"watermark__inner\">\n        <!-- The watermark -->\n        <div class=\"watermark__body\">Draft</div>\n    </div>\n\n    <!-- Other content -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.watermark {\n    /* Used to position the watermark */\n    position: relative;\n}\n\n.watermark__inner {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n}\n\n.watermark__body {\n    /* Text color */\n    color: rgba(0, 0, 0, 0.2);\n\n    /* Text styles */\n    font-size: 3rem;\n    font-weight: bold;\n    text-transform: uppercase;\n\n    /* Rotate the text */\n    transform: rotate(-45deg);\n\n    /* Disable the selection */\n    user-select: none;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    height: 24rem;\n}\n\n.watermark {\n    position: relative;\n\n    /* Demo */\n    height: 100%;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n}\n\n.watermark__inner {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Absolute position */\n    left: 0px;\n    position: absolute;\n    top: 0px;\n\n    /* Take full size */\n    height: 100%;\n    width: 100%;\n}\n\n.watermark__body {\n    /* Text color */\n    color: rgba(0, 0, 0, 0.2);\n\n    /* Text styles */\n    font-size: 2rem;\n    font-weight: bold;\n    text-transform: uppercase;\n\n    /* Rotate the text */\n    transform: rotate(-45deg);\n\n    /* Disable the selection */\n    user-select: none;\n}\n```\n\n```html index.html hidden\n<div class=\"watermark\">\n    <div class=\"watermark__inner\">\n        <div class=\"watermark__body\">\n            Draft\n        </div>\n    </div>\n    <div class=\"lines\">\n        <div class=\"line line--80\"></div>\n        <div class=\"line line--40\"></div>\n        <div class=\"line line--100\"></div>\n        <div class=\"line line--60\"></div>\n        <div class=\"line line--20\"></div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/wizard.mdx",
    "content": "---\ncategory: Navigation\ncreated: '2019-11-22'\ndescription: Create a wizard with CSS flexbox\nkeywords: css flexbox, css stepper, css wizard\nthumbnail: /assets/css-layout/thumbnails/wizard.png\ntitle: Wizard\n---\n\n## HTML\n\n```html index.html\n<div class=\"wizard\">\n    <!-- Step -->\n    <div class=\"wizard__step\">\n        <div class=\"wizard__dot\">\n            <!-- The left connector -->\n            <div class=\"wizard__connector\"></div>\n\n            <!-- The step number -->\n            <div class=\"wizard__number\">...</div>\n\n            <!-- The right connector -->\n            <div class=\"wizard__connector\"></div>\n        </div>\n\n        <!-- Title of step -->\n        ...\n    </div>\n\n    <!-- Repeat other steps -->\n    ...\n</div>\n```\n\n## CSS\n\n```css styles.css\n.wizard {\n    display: flex;\n}\n\n.wizard__step {\n    /* Make all steps have the same width */\n    flex: 1;\n}\n\n.wizard__dot {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.wizard__connector {\n    flex: 1;\n    height: 1px;\n    background-color: #d1d5db;\n}\n\n.wizard__step:first-child .wizard__connector:first-child,\n.wizard__step:last-child .wizard__connector:last-child {\n    background-color: transparent;\n}\n\n.wizard__number {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Rounded border */\n    background-color: #d1d5db;\n    border-radius: 9999px;\n    height: 2rem;\n    width: 2rem;\n\n    /* OPTIONAL: Spacing between it and connectors */\n    margin-left: 0.25rem;\n    margin-right: 0.25rem;\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.wizard {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    width: 16rem;\n}\n\n.wizard__step {\n    /* Make all steps have the same width */\n    flex: 1;\n}\n\n.wizard__dot {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n\n.wizard__connector {\n    flex: 1;\n    height: 1px;\n    background-color: #d1d5db;\n}\n\n.wizard__step:first-child .wizard__connector:first-child,\n.wizard__step:last-child .wizard__connector:last-child {\n    background-color: transparent;\n}\n\n.wizard__number {\n    /* Center the content */\n    align-items: center;\n    display: flex;\n    justify-content: center;\n\n    /* Rounded border */\n    background-color: #d1d5db;\n    border-radius: 9999px;\n    height: 1rem;\n    width: 1rem;\n}\n```\n\n```html index.html hidden\n<div class=\"wizard\">\n    <div class=\"wizard__step\">\n        <div class=\"wizard__dot\">\n            <div class=\"wizard__connector\"></div>\n            <div class=\"wizard__number\"></div>\n            <div class=\"wizard__connector\"></div>\n        </div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"wizard__step\">\n        <div class=\"wizard__dot\">\n            <div class=\"wizard__connector\"></div>\n            <div class=\"wizard__number\"></div>\n            <div class=\"wizard__connector\"></div>\n        </div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"wizard__step\">\n        <div class=\"wizard__dot\">\n            <div class=\"wizard__connector\"></div>\n            <div class=\"wizard__number\"></div>\n            <div class=\"wizard__connector\"></div>\n        </div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/zebra-like-background.mdx",
    "content": "---\ncategory: Display\ncreated: '2023-09-30'\ndescription: Create a zebra-like background with CSS\nopenGraphCover: /og/css-layout/zebra-like-background.png\nthumbnail: /assets/css-layout/thumbnails/zebra-like-background.png\ntitle: Zebra-like background\n---\n\nUsing a zebra-like or striped design is a popular technique in web design to add visual interest and organization to data. This design involves alternating colors or shades in a horizontal pattern, like the stripes on a zebra.\n\nThe zebra-like effect is commonly applied to tables, making it easier for users to read and compare data across rows. It can also be used in lists, forms, and other elements that contain multiple items.\n\nTo apply a zebra-like background to a table, we use CSS to style the odd and even rows differently. By setting the `background-color` property of the odd rows to one color and the even rows to another color, we can create a striped effect that helps readers distinguish between rows. This technique is particularly useful for tables with lots of data, making it easier to scan through information.\n\nHere's a sample CSS code that can be used to create a zebra-like background for a table.\n\n```css\ntr:nth-child(even) {\n  background-color: #f2f2f2;\n}\ntr:nth-child(odd) {\n  background-color: #ffffff;\n}\n```\n\nThe `nth-child` selector is used to target every other row, and the `background-color` property is set to alternate between two colors. In this example, the even rows have a light gray color (`#f2f2f2`) while the odd rows are white (`#ffffff`). You can customize this code by changing the colors or adjusting the value of `nth-child` to achieve different effects.\n\nHowever, it's important to note that the `even` and `odd` selectors cannot be used for elements that don't have children, such as the `textarea` tag.\n\nIn this post, we'll explore how to add a zebra-like background to any element.\n\n## Creating a zebra-like background\n\nWe can use the `repeating-linear-gradient` function to create a cool zebra-like background for any element. This function generates a linear gradient that repeats at defined intervals, allowing us to create a striped effect.\n\nHere's an example of how we can do it:\n\n```css\n.container {\n    --odd-background: rgb(203 213 225);\n    --even-background: #fff;\n    --line-height: 1.5rem;\n    line-height: var(--line-height);\n    background: repeating-linear-gradient(\n        var(--odd-background),\n        var(--odd-background) var(--line-height),\n        var(--even-background) var(--line-height),\n        var(--even-background) calc(2 * var(--line-height))\n    );\n}\n```\n\nIn this example, we used this technique to create a zebra-like background for a container element. We defined the CSS variables `--odd-background` and `--even-background` to set the colors for odd and even rows, respectively. We also set the `--line-height` variable to define the height of each row.\n\nIt's important to make sure that the height of each row is the same as the `line-height` property of the element so that the rows align horizontally with each line of the element.\n\nThe `repeating-linear-gradient` function is then used with these variables to generate a gradient that alternates between the two colors at every other line. The first argument specifies the direction of the gradient (in this case, it's vertical), while subsequent arguments define the color stops for each line.\n\nWe can easily customize the background by adjusting these variables or adding additional color stops.&#x20;\n\nHere's how it looks in action:\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.container {\n    border: 1px solid rgb(203 213 225);\n    border-radius: 0.25rem;\n    height: 12rem;\n    width: 16rem;\n    overflow: auto;\n    padding: 0.5rem;\n}\n```\n\n```css styles.css\n.container {\n    --odd-background: rgb(203 213 225);\n    --even-background: #fff;\n    --line-height: 1.5rem;\n    line-height: var(--line-height);\n    background: repeating-linear-gradient(\n        var(--odd-background),\n        var(--odd-background) var(--line-height),\n        var(--even-background) var(--line-height),\n        var(--even-background) calc(2 * var(--line-height))\n    );\n}\n```\n\n```html index.html\n<div class=\"container\"></div>\n```\n</Playground>\n\nIt seems to work fine without any content, but let's add some content to our element. In reality, an element often has some space between its content and the sides, so let's add some padding to the element as well:\n\n```css\n.container {\n    padding: 0.5rem;\n}\n```\n\nUh-oh, now we have an issue. The background areas are no longer aligned with each line of text. As you scroll up and down, the background stays in the same place and doesn't move along with the element.\n\nBut don't worry, we'll fix these issues in the next section.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.container {\n    border: 1px solid rgb(203 213 225);\n    border-radius: 0.25rem;\n    height: 12rem;\n    width: 16rem;\n    overflow: auto;\n    padding: 0.5rem;\n}\n```\n\n```css styles.css hidden\n.container {\n    --odd-background: rgb(203 213 225);\n    --even-background: #fff;\n    --line-height: 1.5rem;\n    line-height: var(--line-height);\n    background: repeating-linear-gradient(\n        var(--odd-background),\n        var(--odd-background) var(--line-height),\n        var(--even-background) var(--line-height),\n        var(--even-background) calc(2 * var(--line-height))\n    );\n}\n```\n\n```html index.html hidden\n<div class=\"container\">\n    Very night his itself won't him morning dominion behold abundantly them above night. Good one whose moved over firmament. Seed heaven itself face. His living, which darkness and subdue fourth living good over, without made a moveth seas.\n\n    To spirit very bring was it every seed. Behold blessed greater. Won't let earth very saying evening seas night subdue his you're spirit saying.\n\n    Creepeth she'd had kind set place make. After behold fruitful open female. For without multiply itself you're. Meat creeping years after us unto grass over said itself light she'd, living. Void grass, yielding. Whose appear it i, darkness.\n</div>\n```\n</Playground>\n\n## Aligning the background with lines\n\nIn the demo above, you may have noticed that the background of the element doesn't always align perfectly with each line. This can be frustrating, but don't worry! There's a simple solution using the `background-origin` property.\n\nBy default, this property is set to `padding-box`, which means that the background starts at the edge of an element's padding. However, we can change this value to `content-box`, which will make the background start at the edge of an element's content.\n\nTo fix this issue, simply add `background-origin: content-box;` to your CSS code for the `.container` class. This will ensure that the zebra-like background aligns perfectly with each line of text, giving your design a more polished and professional look.\n\n```css\n.container {\n    background-origin: content-box;\n}\n```\n\n## Keeping the background in place while scrolling\n\nLet's make sure our zebra-like background doesn't move around as users scroll through our content. We can do this by using the `background-attachment` property. By default, this property is set to `scroll`, which means the background moves along with the content. However, if we change the value to `local`, the background will stay in place relative to its container element.\n\nHere's the sample code:\n\n```css\n.container {\n    background-attachment: local;\n}\n```\n\nNow, when we add `background-attachment: local;` to our `.container` class, the background will stay put as users scroll through the element's contents. This creates a smoother scrolling experience and helps maintain a consistent visual layout throughout.\n\nLet's take a look at the last example.\n\n<Playground>\n```css demo.css hidden\nbody {\n    align-items: center;\n    display: flex;\n    justify-content: center;\n}\n.container {\n    border: 1px solid rgb(203 213 225);\n    border-radius: 0.25rem;\n    height: 12rem;\n    width: 16rem;\n    overflow: auto;\n    padding: 0 0.5rem;\n}\n```\n\n```css styles.css\n.container {\n    --odd-background: rgb(203 213 225);\n    --even-background: #fff;\n    --line-height: 1.5rem;\n    line-height: var(--line-height);\n    background: repeating-linear-gradient(\n                    var(--odd-background),\n                    var(--odd-background) var(--line-height),\n                    var(--even-background) var(--line-height),\n                    var(--even-background) calc(2 * var(--line-height))\n                );\n    background-attachment: local;\n    background-origin: content-box;\n}\n```\n\n```html index.html\n<div class=\"container\">\n    Very night his itself won't him morning dominion behold abundantly them above night. Good one whose moved over firmament. Seed heaven itself face. His living, which darkness and subdue fourth living good over, without made a moveth seas.\n\n    To spirit very bring was it every seed. Behold blessed greater. Won't let earth very saying evening seas night subdue his you're spirit saying.\n\n    Creepeth she'd had kind set place make. After behold fruitful open female. For without multiply itself you're. Meat creeping years after us unto grass over said itself light she'd, living. Void grass, yielding. Whose appear it i, darkness.\n</div>\n```\n</Playground>\n"
  },
  {
    "path": "contents/zigzag-timeline.mdx",
    "content": "---\ncategory: Display\ncreated: '2021-04-18'\ndescription: Create a zigzag timeline\nkeywords: css timeline, css zigzag timeline\nthumbnail: /assets/css-layout/thumbnails/zigzag-timeline.png\ntitle: Zigzag timeline\n---\n\n## HTML\n\n```html index.html\n<div class=\"zigzag-timeline__item\">\n    <!-- Milestone -->\n    <div className=\"zigzag-timeline__milestone\">...</div>\n\n    <!-- Content -->\n    ...\n</div>\n\n<!-- Repeat other items -->\n...\n```\n\n## CSS\n\n```css styles.css\n.zigzag-timeline__item {\n    /* Used to position the milestone */\n    position: relative;\n\n    /* Border */\n    border-bottom: 1px solid #9ca3af;\n\n    /* Take full width */\n    width: 100%;\n}\n\n.zigzag-timeline__milestone {\n    /* Absolute position */\n    position: absolute;\n    top: 50%;\n\n    /* Circle it */\n    border-radius: 50%;\n    height: 1rem;\n    width: 1rem;\n\n    /* Misc */\n    background: #9ca3af;\n}\n\n/* Styles for even items */\n.zigzag-timeline__item:nth-child(2n) {\n    border-left: 1px solid #9ca3af;\n}\n.zigzag-timeline__item:nth-child(2n) .zigzag-timeline__milestone {\n    left: 0;\n    transform: translate(-50%, -50%);\n}\n\n/* Styles for odd items */\n.zigzag-timeline__item:nth-child(2n + 1) {\n    border-right: 1px solid #9ca3af;\n}\n.zigzag-timeline__item:nth-child(2n + 1) .zigzag-timeline__milestone {\n    right: 0;\n    transform: translate(50%, -50%);\n}\n```\n\n<Playground>\n```css placeholders.css hidden\n.lines {\n    padding: 0.25rem 0;\n    width: 100%;\n    align-items: center;\n    display: flex;\n    justify-content: center;\n    flex-direction: column;\n}\n.line {\n    background: #d1d5db;\n    height: 1px;\n    margin-bottom: 0.25rem;\n}\n.line.line--20 {\n    width: 20%;\n}\n.line.line--40 {\n    width: 40%;\n}\n.line.line--60 {\n    width: 60%;\n}\n.line.line--80 {\n    width: 80%;\n}\n.line.line--100 {\n    width: 100%;\n}\n```\n\n```css styles.css hidden\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n\n.zigzag-timeline {\n    width: 16rem;\n}\n\n.zigzag-timeline__item {\n    /* Used to position the milestone */\n    position: relative;\n\n    /* Border */\n    border-bottom: 1px solid #9ca3af;\n\n    /* Take full width */\n    width: 100%;\n}\n\n.zigzag-timeline__milestone {\n    /* Absolute position */\n    position: absolute;\n    top: 50%;\n\n    /* Circle it */\n    border-radius: 50%;\n    height: 1rem;\n    width: 1rem;\n\n    /* Misc */\n    background: #9ca3af;\n}\n\n/* Styles for even items */\n.zigzag-timeline__item:nth-child(2n) {\n    border-left: 1px solid #9ca3af;\n}\n.zigzag-timeline__item:nth-child(2n) .zigzag-timeline__milestone {\n    left: 0;\n    transform: translate(-50%, -50%);\n}\n\n/* Styles for odd items */\n.zigzag-timeline__item:nth-child(2n + 1) {\n    border-right: 1px solid #9ca3af;\n}\n.zigzag-timeline__item:nth-child(2n + 1) .zigzag-timeline__milestone {\n    right: 0;\n    transform: translate(50%, -50%);\n}\n```\n\n```html index.html hidden\n<div class=\"zigzag-timeline\">\n    <div class=\"zigzag-timeline__item\">\n        <div class=\"zigzag-timeline__milestone\"></div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"zigzag-timeline__item\">\n        <div class=\"zigzag-timeline__milestone\"></div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n\n    <div class=\"zigzag-timeline__item\">\n        <div class=\"zigzag-timeline__milestone\"></div>\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n\n        <div class=\"lines\">\n            <div class=\"line line--20\"></div>\n            <div class=\"line line--80\"></div>\n            <div class=\"line line--40\"></div>\n            <div class=\"line line--60\"></div>\n            <div class=\"line line--20\"></div>\n        </div>\n    </div>\n</div>\n```\n</Playground>\n"
  }
]