{ "data": [ { "id": "border-with-top-triangle", "title": "Border with top triangle", "type": "snippet", "attributes": { "fileName": "border-with-top-triangle.md", "text": "Creates a text container with a triangle at the top.\n\n", "explanation": "\n\n- Use the `:before` and `:after` pseudo-elements to create two triangles. \n- The color of the `:before` triangle should be the same as the container's border color. \n- The color of the `:after` triangle should be the same as the container background color.\n- The border width of the `:before` triangle should be `1px` wider than the `:after` triangle, in order to act as the border.\n- The `:after` triangle should be `1px` to the right of the `:before` triangle to allow for its left border to be shown.\n\n", "browserSupport": { "text": "\n", "supportPercentage": 100 }, "codeBlocks": { "html": "
Select some of this text.
", "css": "::selection {\n background: aquamarine;\n color: black;\n}\n\n.custom-text-selection::selection {\n background: deeppink;\n color: white;\n}", "js": "", "scopedCss": "[data-scope=\"custom-text-selection\"] ::selection {\n background: aquamarine;\n color: black; }\n\n[data-scope=\"custom-text-selection\"] .custom-text-selection::selection {\n background: deeppink;\n color: white; }\n" }, "tags": [ "visual", "beginner" ] }, "meta": { "hash": "1c29d55847263d12852dfd752653287237c885cadb369ee3db28701029f8bcc2", "firstSeen": "1519564479", "lastUpdated": "1583441571", "updateCount": 16, "authorCount": 6 } }, { "id": "disable-selection", "title": "Disable selection", "type": "snippet", "attributes": { "fileName": "disable-selection.md", "text": "Makes the content unselectable.\n\n", "explanation": "\n\n- `user-select: none` specifies that the text cannot be selected.\n\n_Note: This is not a secure method to prevent users from copying content._\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=user-select-none\n", "supportPercentage": 99.7 }, "codeBlocks": { "html": "You can select me.
\nYou can't select me!
", "css": ".unselectable {\n user-select: none;\n}", "js": "", "scopedCss": "[data-scope=\"disable-selection\"] .unselectable {\n user-select: none; }\n" }, "tags": [ "interactivity", "beginner" ] }, "meta": { "hash": "e12b82431230f27651567c0c23dd5f26eca9e4ded24bb6f3175432ab66256096", "firstSeen": "1519664998", "lastUpdated": "1583441571", "updateCount": 15, "authorCount": 5 } }, { "id": "display-table-centering", "title": "Display table centering", "type": "snippet", "attributes": { "fileName": "display-table-centering.md", "text": "Vertically and horizontally centers a child element within its parent element using `display: table` (as an alternative to `flexbox`).\n\n", "explanation": "\n\n1. `display: table` on '.center' allows the element to behave like a `| HTML element.\n4. `text-align: center` on '.center > span' centers the child element horizontally.\n5. `vertical-align: middle` on '.center > span' centers the child element vertically.\n\n- The outer parent ('.container' in this case) must have a fixed height and width.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#search=display%3A%20table\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": " \n ",
"css": ".container {\n border: 1px solid #333;\n height: 250px;\n width: 250px;\n}\n\n.center {\n display: table;\n height: 100%;\n width: 100%;\n}\n\n.center > span {\n display: table-cell;\n text-align: center;\n vertical-align: middle;\n}",
"js": "",
"scopedCss": "[data-scope=\"display-table-centering\"] .container {\n border: 1px solid #333;\n height: 250px;\n width: 250px; }\n\n[data-scope=\"display-table-centering\"] .center {\n display: table;\n height: 100%;\n width: 100%; }\n\n[data-scope=\"display-table-centering\"] .center > span {\n display: table-cell;\n text-align: center;\n vertical-align: middle; }\n"
},
"tags": [
"layout",
"intermediate"
]
},
"meta": {
"hash": "83c7806b0be2e50ca34f313912f9cb90682852790e6d0105a635f781212fa5b1",
"firstSeen": "1522361754",
"lastUpdated": "1583441571",
"updateCount": 14,
"authorCount": 5
}
},
{
"id": "donut-spinner",
"title": "Donut spinner",
"type": "snippet",
"attributes": {
"fileName": "donut-spinner.md",
"text": "Creates a donut spinner that can be used to indicate the loading of content.\n\n",
"explanation": "\n\n- Use a semi-transparent `border` for the whole element, except one side that will serve as the loading indicator for the donut. Use `animation` to rotate the element.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-animation\n- https://caniuse.com/#feat=transforms2d\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "",
"css": "@keyframes donut-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.donut {\n display: inline-block;\n border: 4px solid rgba(0, 0, 0, 0.1);\n border-left-color: #7983ff;\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: donut-spin 1.2s linear infinite;\n}",
"js": "",
"scopedCss": "@keyframes donut-spin {\n 0% {\n transform: rotate(0deg); }\n 100% {\n transform: rotate(360deg); } }\n\n[data-scope=\"donut-spinner\"] .donut {\n display: inline-block;\n border: 4px solid rgba(0, 0, 0, 0.1);\n border-left-color: #7983ff;\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: donut-spin 1.2s linear infinite; }\n"
},
"tags": [
"animation",
"intermediate"
]
},
"meta": {
"hash": "e9d886bf0718a408e719f978370e4e32e62222322c5641fb62be2968f6f95884",
"firstSeen": "1519745555",
"lastUpdated": "1583441571",
"updateCount": 13,
"authorCount": 4
}
},
{
"id": "drop-cap",
"title": "Drop cap",
"type": "snippet",
"attributes": {
"fileName": "drop-cap.md",
"text": "Makes the first letter in the first paragraph bigger than the rest of the text - often used to signify the beginning of a new section.\n\n",
"explanation": "\n\n- Use the `::first-letter` pseudo-element to style the first element of the paragraph, use the `:first-child` selector to select only the first paragraph.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=first-letter\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Centered content \nLorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam commodo ligula quis tincidunt cursus. Integer consectetur tempor ex eget hendrerit. Cras facilisis sodales odio nec maximus. Pellentesque lacinia convallis libero, rhoncus tincidunt ante dictum at. Nullam facilisis lectus tellus, sit amet congue erat sodales commodo. \nDonec magna erat, imperdiet non odio sed, sodales tempus magna. Integer vitae orci lectus. Nullam consectetur orci at pellentesque efficitur. ", "css": "p:first-child::first-letter {\n color: #5f79ff;\n float: left;\n margin: 0 8px 0 4px;\n font-size: 3rem;\n font-weight: bold;\n line-height: 1;\n}", "js": "", "scopedCss": "[data-scope=\"drop-cap\"] p:first-child::first-letter {\n color: #5f79ff;\n float: left;\n margin: 0 8px 0 4px;\n font-size: 3rem;\n font-weight: bold;\n line-height: 1; }\n" }, "tags": [ "visual", "beginner" ] }, "meta": { "hash": "e7859bc139713ffe59a05904f6175e9578ad111ebe3405d58599846c44801606", "firstSeen": "1539406050", "lastUpdated": "1569669005", "updateCount": 4, "authorCount": 3 } }, { "id": "dynamic-shadow", "title": "Dynamic shadow", "type": "snippet", "attributes": { "fileName": "dynamic-shadow.md", "text": "Creates a shadow similar to `box-shadow` but based on the colors of the element itself.\n\n", "explanation": "\n\n1. `position: relative` on the element establishes a Cartesian positioning context for psuedo-elements.\n2. `z-index: 1` establishes a new stacking context.\n3. `::after` defines a pseudo-element.\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 100%` and `height: 100%` sizes the pseudo-element to fill its parent's dimensions, making it equal in size.\n6. `background: inherit` causes the pseudo-element to inherit the linear gradient specified on the element.\n7. `top: 0.5rem` offsets the pseudo-element down slightly from its parent.\n8. `filter: blur(0.4rem)` will blur the pseudo-element to create the appearance of a shadow underneath.\n9. `opacity: 0.7` makes the pseudo-element partially transparent.\n10. `z-index: -1` positions the pseudo-element behind the parent but in front of the background.\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=css-filters\n", "supportPercentage": 100 }, "codeBlocks": { "html": "", "css": ".dynamic-shadow {\n position: relative;\n width: 10rem;\n height: 10rem;\n background: linear-gradient(75deg, #6d78ff, #00ffb8);\n z-index: 1;\n}\n\n.dynamic-shadow::after {\n content: '';\n width: 100%;\n height: 100%;\n position: absolute;\n background: inherit;\n top: 0.5rem;\n filter: blur(0.4rem);\n opacity: 0.7;\n z-index: -1;\n}", "js": "", "scopedCss": "[data-scope=\"dynamic-shadow\"] .dynamic-shadow {\n position: relative;\n width: 10rem;\n height: 10rem;\n background: linear-gradient(75deg, #6d78ff, #00ffb8);\n z-index: 1; }\n\n[data-scope=\"dynamic-shadow\"] .dynamic-shadow::after {\n content: '';\n width: 100%;\n height: 100%;\n position: absolute;\n background: inherit;\n top: 0.5rem;\n filter: blur(0.4rem);\n opacity: 0.7;\n z-index: -1; }\n" }, "tags": [ "visual", "intermediate" ] }, "meta": { "hash": "d22e3c4c20c8c3effbb25e59de03f1153f1d7808b695bef253ea90d657d59012", "firstSeen": "1520250696", "lastUpdated": "1583441571", "updateCount": 12, "authorCount": 4 } }, { "id": "easing-variables", "title": "Easing variables", "type": "snippet", "attributes": { "fileName": "easing-variables.md", "text": "Variables that can be reused for `transition-timing-function` properties, more powerful than the built-in `ease`, `ease-in`, `ease-out` and `ease-in-out`.\n\n", "explanation": "\n\n- The variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document.\n- In HTML, `:root` represents the `` element and is identical to the selector `html`, except that its specificity is higher.\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=css-variables\n", "supportPercentage": 98.68 }, "codeBlocks": { "html": "Hover ",
"css": ":root {\n /* Place variables in here to use globally */\n}\n\n.easing-variables {\n --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);\n --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);\n --ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);\n --ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);\n --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);\n --ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);\n\n --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);\n --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);\n --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);\n --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);\n --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);\n --ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);\n\n --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);\n --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);\n --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);\n --ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1);\n --ease-in-out-expo: cubic-bezier(1, 0, 0, 1);\n --ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.15, 0.86);\n display: inline-block;\n width: 75px;\n height: 75px;\n padding: 10px;\n color: white;\n line-height: 50px;\n text-align: center;\n background: #333;\n transition: transform 1s var(--ease-out-quart);\n}\n\n.easing-variables:hover {\n transform: rotate(45deg);\n}",
"js": "",
"scopedCss": "[data-scope=\"easing-variables\"] :root {\n /* Place variables in here to use globally */ }\n\n[data-scope=\"easing-variables\"] .easing-variables {\n --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);\n --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);\n --ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);\n --ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);\n --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);\n --ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);\n --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);\n --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);\n --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);\n --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);\n --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);\n --ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);\n --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);\n --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);\n --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);\n --ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1);\n --ease-in-out-expo: cubic-bezier(1, 0, 0, 1);\n --ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.15, 0.86);\n display: inline-block;\n width: 75px;\n height: 75px;\n padding: 10px;\n color: white;\n line-height: 50px;\n text-align: center;\n background: #333;\n transition: transform 1s var(--ease-out-quart); }\n\n[data-scope=\"easing-variables\"] .easing-variables:hover {\n transform: rotate(45deg); }\n"
},
"tags": [
"animation",
"beginner"
]
},
"meta": {
"hash": "107cca03431b28d491f871d2267992a7da5b9f62765325bf5f57236574968ac2",
"firstSeen": "1519564479",
"lastUpdated": "1583441571",
"updateCount": 13,
"authorCount": 5
}
},
{
"id": "etched-text",
"title": "Etched text",
"type": "snippet",
"attributes": {
"fileName": "etched-text.md",
"text": "Creates an effect where text appears to be \"etched\" or engraved into the background.\n\n",
"explanation": "\n\n- `text-shadow: 0 2px white` creates a white shadow offset `0px` horizontally and `2px` vertically from the origin position.\n- The background must be darker than the shadow for the effect to work.\n- The text color should be slightly faded to make it look like it's engraved/carved out of the background.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-textshadow\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "I appear etched into the background. ", "css": ".etched-text {\n text-shadow: 0 2px white;\n font-size: 1.5rem;\n font-weight: bold;\n color: #b8bec5;\n}", "js": "", "scopedCss": "[data-scope=\"etched-text\"] .etched-text {\n text-shadow: 0 2px white;\n font-size: 1.5rem;\n font-weight: bold;\n color: #b8bec5; }\n" }, "tags": [ "visual", "intermediate" ] }, "meta": { "hash": "68da5c2e7399979db3aeb1022d13b0490fc71d55d068597544954706c7027bef", "firstSeen": "1519564479", "lastUpdated": "1583441571", "updateCount": 12, "authorCount": 4 } }, { "id": "evenly-distributed-children", "title": "Evenly distributed children", "type": "snippet", "attributes": { "fileName": "evenly-distributed-children.md", "text": "Evenly distributes child elements within a parent element.\n\n", "explanation": "\n\n1. `display: flex` enables flexbox.\n2. `justify-content: space-between` evenly distributes child elements horizontally. The first item is positioned at the left edge, while the last item is positioned at the right edge.\n\n_Note: Alternatively, use `justify-content: space-around` to distribute the children with space around them, rather than between them._\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=flexbox\n", "supportPercentage": 100 }, "codeBlocks": { "html": "\n ",
"css": ".evenly-distributed-children {\n display: flex;\n justify-content: space-between;\n}",
"js": "",
"scopedCss": "[data-scope=\"evenly-distributed-children\"] .evenly-distributed-children {\n display: flex;\n justify-content: space-between; }\n"
},
"tags": [
"layout",
"intermediate"
]
},
"meta": {
"hash": "5b4505f5052c203bbf0f79410af09801487250b65591fb5113da40b27c6cfb08",
"firstSeen": "1519818422",
"lastUpdated": "1583441571",
"updateCount": 11,
"authorCount": 4
}
},
{
"id": "fit-image-in-container",
"title": "Fit image in container",
"type": "snippet",
"attributes": {
"fileName": "fit-image-in-container.md",
"text": "Changes the fit and position of an image within its container while preserving its aspect ratio. Previously only possible using a background image and the `background-size` property.\n\n",
"explanation": "\n\n- `object-fit: contain` fits the entire image within the container while preserving its aspect ratio.\n- `object-fit: cover` fills the container with the image while preserving its aspect ratio.\n- `object-position: [x] [y]` positions the image within the container.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=object-fit\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Item1 \nItem2 \nItem3 \nCentered content. \n \n ",
"css": "form {\n border: 3px solid #2d98da;\n color: #000000;\n padding: 4px;\n}\n\nform:focus-within {\n background: #f7b731;\n color: #000000;\n}",
"js": "",
"scopedCss": "[data-scope=\"focus-within\"] form {\n border: 3px solid #2d98da;\n color: #000000;\n padding: 4px; }\n\n[data-scope=\"focus-within\"] form:focus-within {\n background: #f7b731;\n color: #000000; }\n"
},
"tags": [
"visual",
"interactivity",
"intermediate"
]
},
"meta": {
"hash": "9fa1ed419618b640c286644ceae4235101b0f01014c7d82f944a76c9bbc6e39c",
"firstSeen": "1540256293",
"lastUpdated": "1583441571",
"updateCount": 12,
"authorCount": 4
}
},
{
"id": "fullscreen",
"title": "Fullscreen",
"type": "snippet",
"attributes": {
"fileName": "fullscreen.md",
"text": "The `:fullscreen` CSS pseudo-element represents an element that's displayed when the browser is in fullscreen mode.\n\n",
"explanation": "\n\n- `:fullscreen` CSS pseudo-element selector is used to select and style an element that is being displayed in fullscreen mode.\n\n",
"browserSupport": {
"text": "\n\n- https://developer.mozilla.org/en-US/docs/Web/CSS/:fullscreen\n- https://caniuse.com/#feat=fullscreen\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "\n ",
"css": ".container {\n margin: 40px auto;\n max-width: 700px;\n}\n\n.element {\n padding: 20px;\n height: 300px;\n width: 100%;\n background-color: skyblue;\n box-sizing: border-box;\n}\n\n.element p {\n text-align: center;\n color: white;\n font-size: 3em;\n}\n\n.element:-ms-fullscreen p {\n visibility: visible;\n}\n\n.element:fullscreen {\n background-color: #e4708a;\n width: 100vw;\n height: 100vh;\n}",
"js": "",
"scopedCss": "[data-scope=\"fullscreen\"] .container {\n margin: 40px auto;\n max-width: 700px; }\n\n[data-scope=\"fullscreen\"] .element {\n padding: 20px;\n height: 300px;\n width: 100%;\n background-color: skyblue;\n box-sizing: border-box; }\n\n[data-scope=\"fullscreen\"] .element p {\n text-align: center;\n color: white;\n font-size: 3em; }\n\n[data-scope=\"fullscreen\"] .element:-ms-fullscreen p {\n visibility: visible; }\n\n[data-scope=\"fullscreen\"] .element:fullscreen {\n background-color: #e4708a;\n width: 100vw;\n height: 100vh; }\n"
},
"tags": [
"visual",
"advanced"
]
},
"meta": {
"hash": "a58ee2656271bb14a6a51e91517ca08f5c6ee86f9f3286e977507af49363cd86",
"firstSeen": "1547291320",
"lastUpdated": "1583441571",
"updateCount": 10,
"authorCount": 4
}
},
{
"id": "ghost-trick",
"title": "Ghost trick",
"type": "snippet",
"attributes": {
"fileName": "ghost-trick.md",
"text": "Vertically centers an element in another.\n\n",
"explanation": "\n\n- Use the style of a `:before` pseudo-element to vertically align inline elements without changing their `position` property.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=inline-block\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Click the button below to enter the element into fullscreen mode. \nI change color in fullscreen mode! \n \n \n ",
"css": ".ghosting {\n height: 300px;\n background: #0ff;\n}\n\n.ghosting:before {\n content: '';\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n}\n\np {\n display: inline-block;\n vertical-align: middle;\n}",
"js": "",
"scopedCss": "[data-scope=\"ghost-trick\"] .ghosting {\n height: 300px;\n background: #0ff; }\n\n[data-scope=\"ghost-trick\"] .ghosting:before {\n content: '';\n display: inline-block;\n height: 100%;\n vertical-align: middle; }\n\n[data-scope=\"ghost-trick\"] p {\n display: inline-block;\n vertical-align: middle; }\n"
},
"tags": [
"layout",
"intermediate"
]
},
"meta": {
"hash": "0515f03b1505eafa21e0d0d7377facbe4aaa9159996906dd4ed2857ee137073a",
"firstSeen": "1540097710",
"lastUpdated": "1583441571",
"updateCount": 11,
"authorCount": 5
}
},
{
"id": "gradient-text",
"title": "Gradient text",
"type": "snippet",
"attributes": {
"fileName": "gradient-text.md",
"text": "Gives text a gradient color.\n\n",
"explanation": "\n\n1. `background: -webkit-linear-gradient(...)` gives the text element a gradient background.\n2. `webkit-text-fill-color: transparent` fills the text with a transparent color.\n3. `webkit-background-clip: text` clips the background with the text, filling the text with the gradient background as the color.\n\n",
"browserSupport": {
"text": "\n\n⚠️ Uses non-standard properties.\n\n- https://caniuse.com/#feat=text-stroke\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Vertically centered without changing the position property. Gradient text ", "css": ".gradient-text {\n background: -webkit-linear-gradient(pink, red);\n -webkit-text-fill-color: transparent;\n -webkit-background-clip: text;\n}", "js": "", "scopedCss": "[data-scope=\"gradient-text\"] .gradient-text {\n background: -webkit-linear-gradient(pink, red);\n -webkit-text-fill-color: transparent;\n -webkit-background-clip: text; }\n" }, "tags": [ "visual", "intermediate" ] }, "meta": { "hash": "9620da48fb82b48a7c6b681854707b622a18c158f2db88c816e3b9c0d9b04523", "firstSeen": "1519564479", "lastUpdated": "1583441571", "updateCount": 11, "authorCount": 4 } }, { "id": "grid-centering", "title": "Grid centering", "type": "snippet", "attributes": { "fileName": "grid-centering.md", "text": "Horizontally and vertically centers a child element within a parent element using `grid`.\n\n", "explanation": "\n\n1. `display: grid` creates a grid layout\n2. `justify-content: center` centers the child horizontally.\n3. `align-items: center` centers the child vertically.\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=css-grid\n", "supportPercentage": 99.05 }, "codeBlocks": { "html": "\n ",
"css": ".grid-centering {\n display: grid;\n justify-content: center;\n align-items: center;\n height: 100px;\n}",
"js": "",
"scopedCss": "[data-scope=\"grid-centering\"] .grid-centering {\n display: grid;\n justify-content: center;\n align-items: center;\n height: 100px; }\n"
},
"tags": [
"layout",
"beginner"
]
},
"meta": {
"hash": "c6ce214d8597cc068355174c86c7c3e8be586c68fb7fb18666d644b4458c0a22",
"firstSeen": "1520072039",
"lastUpdated": "1583441571",
"updateCount": 13,
"authorCount": 5
}
},
{
"id": "hairline-border",
"title": "Hairline border",
"type": "snippet",
"attributes": {
"fileName": "hairline-border.md",
"text": "Gives an element a border equal to 1 native device pixel in width, which can look very sharp and crisp.\n\n",
"explanation": "\n\n1. `box-shadow`, when only using spread, adds a pseudo-border which can use subpixels \\*.\n2. Use `@media (min-resolution: ...)` to check the device pixel ratio (`1dppx` equals 96 DPI), setting the spread of the `box-shadow` equal to `1 / dppx`.\n\n",
"browserSupport": {
"text": "\n\n⚠️ Needs alternate syntax and JavaScript user agent checking for full support.\n\n- https://caniuse.com/#feat=css-boxshadow\n- https://caniuse.com/#feat=css-media-resolution\n\nCentered content. \n\n\n\\* Chrome does not support subpixel values on `border`. Safari does not support subpixel values on `box-shadow`. Firefox supports subpixel values on both.\n", "supportPercentage": 100 }, "codeBlocks": { "html": " text ",
"css": ".hairline-border {\n box-shadow: 0 0 0 1px;\n}\n\n@media (min-resolution: 2dppx) {\n .hairline-border {\n box-shadow: 0 0 0 0.5px;\n }\n}\n\n@media (min-resolution: 3dppx) {\n .hairline-border {\n box-shadow: 0 0 0 0.33333333px;\n }\n}\n\n@media (min-resolution: 4dppx) {\n .hairline-border {\n box-shadow: 0 0 0 0.25px;\n }\n}",
"js": "",
"scopedCss": "[data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 1px; }\n\n@media (min-resolution: 2dppx) {\n [data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 0.5px; } }\n\n@media (min-resolution: 3dppx) {\n [data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 0.33333333px; } }\n\n@media (min-resolution: 4dppx) {\n [data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 0.25px; } }\n"
},
"tags": [
"visual",
"advanced"
]
},
"meta": {
"hash": "3d33020a7ae2dc94aa6cf41803897323068158faff9133ce5d60cb927d647a9f",
"firstSeen": "1519564479",
"lastUpdated": "1583441571",
"updateCount": 13,
"authorCount": 4
}
},
{
"id": "hamburger-button",
"title": "Hamburger Button",
"type": "snippet",
"attributes": {
"fileName": "hamburger-button.md",
"text": "Displays a hamburger menu which transitions to a cross on hover.\n\n",
"explanation": "\n\n- Use a `.hamburger-menu` container `div` which contains the top, bottom, and middle bars.\n- The container is set to be a flex container (`display: flex`) with `flex-direction` to be `column` and `flex-wrap` to be `wrap` (alternatively, you can set both properties by a shorthand `flex-flow: column wrap`).\n- Add distance between the bars using `justify-content: space-between`.\n- The animation has 3 parts: top and bottom bars transforming to 45 degree angles (`rotate(45deg)`), and the middle bar fading away by setting `opacity: 0`.\n- The `transform-origin` is set to `left` so the bars rotate around the left point.\n- Set `transition all 0.5s` so that both `transform` and `opacity` properties are animated for half a second.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=flexbox\n- https://caniuse.com/#feat=css-transitions\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "",
"css": ".hamburger-menu {\n display: flex;\n flex-direction: column;\n flex-wrap: wrap;\n justify-content: space-between;\n height: 2.5rem;\n width: 2.5rem;\n cursor: pointer;\n}\n\n.hamburger-menu .bar {\n height: 5px;\n background: black;\n border-radius: 5px;\n margin: 3px 0px;\n transform-origin: left;\n transition: all 0.5s;\n}\n\n.hamburger-menu:hover .top {\n transform: rotate(45deg);\n}\n\n.hamburger-menu:hover .middle {\n opacity: 0;\n}\n\n.hamburger-menu:hover .bottom {\n transform: rotate(-45deg);\n}",
"js": "",
"scopedCss": "[data-scope=\"hamburger-button\"] .hamburger-menu {\n display: flex;\n flex-direction: column;\n flex-wrap: wrap;\n justify-content: space-between;\n height: 2.5rem;\n width: 2.5rem;\n cursor: pointer; }\n\n[data-scope=\"hamburger-button\"] .hamburger-menu .bar {\n height: 5px;\n background: black;\n border-radius: 5px;\n margin: 3px 0px;\n transform-origin: left;\n transition: all 0.5s; }\n\n[data-scope=\"hamburger-button\"] .hamburger-menu:hover .top {\n transform: rotate(45deg); }\n\n[data-scope=\"hamburger-button\"] .hamburger-menu:hover .middle {\n opacity: 0; }\n\n[data-scope=\"hamburger-button\"] .hamburger-menu:hover .bottom {\n transform: rotate(-45deg); }\n"
},
"tags": [
"interactivity",
"beginner"
]
},
"meta": {
"hash": "06f323835f89d7e055e932ee67c23a9c5d2edeb7e62c1029c0528238e17a08f8",
"firstSeen": "1570668578",
"lastUpdated": "1574679180",
"updateCount": 11,
"authorCount": 7
}
},
{
"id": "height-transition",
"title": "Height transition",
"type": "snippet",
"attributes": {
"fileName": "height-transition.md",
"text": "Transitions an element's height from `0` to `auto` when its height is unknown.\n\n",
"explanation": "\n\n1. `transition: max-height: 0.5s cubic-bezier(...)` specifies that changes to `max-height` should be transitioned over 0.5 seconds, using an `ease-out-quint` timing function.\n2. `overflow: hidden` prevents the contents of the hidden element from overflowing its container.\n3. `max-height: 0` specifies that the element has no height initially.\n4. `.target:hover > .el` specifies that when the parent is hovered over, target a child `.el` within it and use the `--max-height` variable which was defined by JavaScript.\n\n\n\n1. `el.scrollHeight` is the height of the element including overflow, which will change dynamically based on the content of the element.\n2. `el.style.setProperty(...)` sets the `--max-height` CSS variable which is used to specify the `max-height` of the element the target is hovered over, allowing it to transition smoothly from 0 to auto.\n\n", "browserSupport": { "text": "\n\n Requires JavaScript \n⚠️ Causes reflow on each animation frame, which will be laggy if there are a large number of elements beneath the element that is transitioning in height.\n\n- https://caniuse.com/#feat=css-variables\n- https://caniuse.com/#feat=css-transitions\n",
"supportPercentage": 98.68
},
"codeBlocks": {
"html": "\n Hover me to see a height transition.\n ",
"css": ".el {\n transition: max-height 0.5s;\n overflow: hidden;\n max-height: 0;\n}\n\n.trigger:hover > .el {\n max-height: var(--max-height);\n}",
"js": "var el = document.querySelector('.el')\nvar height = el.scrollHeight\nel.style.setProperty('--max-height', height + 'px')",
"scopedCss": "[data-scope=\"height-transition\"] .el {\n transition: max-height 0.5s;\n overflow: hidden;\n max-height: 0; }\n\n[data-scope=\"height-transition\"] .trigger:hover > .el {\n max-height: var(--max-height); }\n"
},
"tags": [
"animation",
"intermediate"
]
},
"meta": {
"hash": "266740a9a3a65bcfede78868170a741359409690921ef9b57f73593b8b6d6e3f",
"firstSeen": "1521276782",
"lastUpdated": "1583441571",
"updateCount": 12,
"authorCount": 4
}
},
{
"id": "hover-shadow-box-animation",
"title": "Hover shadow box animation",
"type": "snippet",
"attributes": {
"fileName": "hover-shadow-box-animation.md",
"text": "Creates a shadow box around the text when it is hovered.\n\n",
"explanation": "\n\n1. `display: inline-block` to set width and length for `p` element thus making it an `inline-block`.\n2. Set `transform: perspective(1px)` to give element a 3D space by affecting the distance between the Z plane and the user and `translate(0)` to reposition the `p` element along z-axis in 3D space.\n3. `box-shadow:` to set up the box.\n4. `transparent` to make box transparent.\n5. `transition-property` to enable transitions for both `box-shadow` and `transform`.\n6. `:hover` to activate whole css when hovering is done until `active`.\n7. `transform: scale(1.2)` to change the scale, magnifying the text.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=transforms3d\n- https://caniuse.com/#feat=css-transitions\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "content \nBox it! ", "css": ".hover-shadow-box-animation {\n display: inline-block;\n vertical-align: middle;\n transform: perspective(1px) translateZ(0);\n box-shadow: 0 0 1px transparent;\n margin: 10px;\n transition-duration: 0.3s;\n transition-property: box-shadow, transform;\n}\n\n.hover-shadow-box-animation:hover,\n.hover-shadow-box-animation:focus,\n.hover-shadow-box-animation:active {\n box-shadow: 1px 10px 10px -10px rgba(0, 0, 24, 0.5);\n transform: scale(1.2);\n}", "js": "", "scopedCss": "[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation {\n display: inline-block;\n vertical-align: middle;\n transform: perspective(1px) translateZ(0);\n box-shadow: 0 0 1px transparent;\n margin: 10px;\n transition-duration: 0.3s;\n transition-property: box-shadow, transform; }\n\n[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation:hover,\n[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation:focus,\n[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation:active {\n box-shadow: 1px 10px 10px -10px rgba(0, 0, 24, 0.5);\n transform: scale(1.2); }\n" }, "tags": [ "animation", "intermediate" ] }, "meta": { "hash": "b66a2a4c4c80fd0c64aaa15a9139e1273d6854fd75f0550d2625578792df828f", "firstSeen": "1520372515", "lastUpdated": "1583441571", "updateCount": 17, "authorCount": 6 } }, { "id": "hover-underline-animation", "title": "Hover underline animation", "type": "snippet", "attributes": { "fileName": "hover-underline-animation.md", "text": "Creates an animated underline effect when the text is hovered over.\n\n", "explanation": "\n\n1. `display: inline-block` makes the block `p` an `inline-block` to prevent the underline from spanning the entire parent width rather than just the content (text).\n2. `position: relative` on the element establishes a Cartesian positioning context for pseudo-elements.\n3. `::after` defines a pseudo-element.\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 100%` ensures the pseudo-element spans the entire width of the text block.\n6. `transform: scaleX(0)` initially scales the pseudo element to 0 so it has no width and is not visible.\n7. `bottom: 0` and `left: 0` position it to the bottom left of the block.\n8. `transition: transform 0.25s ease-out` means changes to `transform` will be transitioned over 0.25 seconds with an `ease-out` timing function.\n9. `transform-origin: bottom right` means the transform anchor point is positioned at the bottom right of the block.\n10. `:hover::after` then uses `scaleX(1)` to transition the width to 100%, then changes the `transform-origin` to `bottom left` so that the anchor point is reversed, allowing it transition out in the other direction when hovered off.\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=transforms2d\n- https://caniuse.com/#feat=css-transitions\n", "supportPercentage": 100 }, "codeBlocks": { "html": "Hover this text to see the effect! ", "css": ".hover-underline-animation {\n display: inline-block;\n position: relative;\n color: #0087ca;\n}\n\n.hover-underline-animation::after {\n content: '';\n position: absolute;\n width: 100%;\n transform: scaleX(0);\n height: 2px;\n bottom: 0;\n left: 0;\n background-color: #0087ca;\n transform-origin: bottom right;\n transition: transform 0.25s ease-out;\n}\n\n.hover-underline-animation:hover::after {\n transform: scaleX(1);\n transform-origin: bottom left;\n}", "js": "", "scopedCss": "[data-scope=\"hover-underline-animation\"] .hover-underline-animation {\n display: inline-block;\n position: relative;\n color: #0087ca; }\n\n[data-scope=\"hover-underline-animation\"] .hover-underline-animation::after {\n content: '';\n position: absolute;\n width: 100%;\n transform: scaleX(0);\n height: 2px;\n bottom: 0;\n left: 0;\n background-color: #0087ca;\n transform-origin: bottom right;\n transition: transform 0.25s ease-out; }\n\n[data-scope=\"hover-underline-animation\"] .hover-underline-animation:hover::after {\n transform: scaleX(1);\n transform-origin: bottom left; }\n" }, "tags": [ "animation", "advanced" ] }, "meta": { "hash": "b67109fcb1f945f671c62fc67c3bff9f32290bbfb0ef739995f1a94fd952dfd5", "firstSeen": "1519816762", "lastUpdated": "1583441571", "updateCount": 17, "authorCount": 4 } }, { "id": "last-item-with-remaining-available-height", "title": "Last item with remaining available height", "type": "snippet", "attributes": { "fileName": "last-item-with-remaining-available-height.md", "text": "Take advantage of available viewport space by giving the last element the remaining available space in current viewport, even when resizing the window.\n\n", "explanation": "\n\n1. `height: 100%` sets the height of container as viewport height.\n2. `display: flex` creates a flexbox layout.\n3. `flex-direction: column` set the direction of flex items' order from top to down.\n4. `flex-grow: 1` the flexbox will apply remaining available space of container to last child element.\n\n- The parent must have a viewport height. `flex-grow: 1` could be applied to the first or second element, which will occupy all available space.\n\n", "browserSupport": { "text": "\n\n- https://caniuse.com/#feat=flexbox\n", "supportPercentage": 100 }, "codeBlocks": { "html": "\n ",
"css": "html,\nbody {\n height: 100%;\n margin: 0;\n}\n\n.container {\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n\n.container > div:last-child {\n background-color: tomato;\n flex: 1;\n}",
"js": "",
"scopedCss": "[data-scope=\"last-item-with-remaining-available-height\"] html,\n[data-scope=\"last-item-with-remaining-available-height\"] body {\n height: 100%;\n margin: 0; }\n\n[data-scope=\"last-item-with-remaining-available-height\"] .container {\n height: 100%;\n display: flex;\n flex-direction: column; }\n\n[data-scope=\"last-item-with-remaining-available-height\"] .container > div:last-child {\n background-color: tomato;\n flex: 1; }\n"
},
"tags": [
"layout",
"intermediate"
]
},
"meta": {
"hash": "65a60a1552f0cc9cc1fbb1cfb30bb1a6a0e35f7313cb3d209c540a4483333370",
"firstSeen": "1538367351",
"lastUpdated": "1583441571",
"updateCount": 10,
"authorCount": 3
}
},
{
"id": "lobotomizedOwlSelector",
"title": "Lobotomized Owl Selector",
"type": "snippet",
"attributes": {
"fileName": "lobotomizedOwlSelector.md",
"text": "Sets an automatically inherited margin for all elements that follow other elements in the document.\n\n",
"explanation": "\n\n- In this example, all elements in the flow of the document that follow other elements will receive `margin-top: 1.5em`.\n- This example assumes that the paragraphs' `font-size` is 1em and its `line-height` is 1.5.\n_Note: You can read [this article](https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/_) for a more detailed explanation._\n\n",
"browserSupport": {
"text": "\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Div 1 \n Div 2 \n Div 3 \n\n ",
"css": "* + * {\n margin-top: 1.5em;\n}",
"js": "",
"scopedCss": "[data-scope=\"lobotomizedOwlSelector\"] * + * {\n margin-top: 1.5em; }\n"
},
"tags": [
"layout",
"beginner"
]
},
"meta": {
"hash": "bf9ee261ea338f5c07c4df24ac6c976d9d0584de01552b0955a205628b947e53",
"firstSeen": "1569946901",
"lastUpdated": "1583441571",
"updateCount": 3,
"authorCount": 3
}
},
{
"id": "masonry-layout",
"title": "Masonry Layout",
"type": "snippet",
"attributes": {
"fileName": "masonry-layout.md",
"text": "Creates a vertical masonry layout using HTML and CSS.\n\n",
"explanation": "\n\n- Create a masonry-style layout that consists of \"bricks\" that fall into each other with either a fixed `width` (vertical layout) or a fixed `height` (horizontal layout), forming a perfect fit. Especially useful when working with images.\n- `.masonry-container` is the container for the masonry layout. Within that container, there's a `div.masonry-columns`, which will automatically put each child element, `.masonry-brick`, into the layout. \n- `.masonry-brick` must be have `display: block` to allow the layout to flow properly, while the `:first-child` of this class should have a different `margin` to account for its positioning.\n- CSS variables are used to allow for greater flexibility for the layout, while media queries ensure that the layout flows responsively in different viewport sizes.\n\n",
"browserSupport": {
"text": "\n\n- https://www.caniuse.com/#feat=css-variables\n- https://www.caniuse.com/#feat=calc\n- https://www.caniuse.com/#feat=mdn-css_properties_column-count\n- https://www.caniuse.com/#feat=mdn-css_properties_column-width\n- https://www.caniuse.com/#feat=mdn-css_properties_column-gap_multicol_context\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Parent 01 \n Parent 02\n \n Child 01 \n Child 02 \n Parent 03 \n\n ",
"css": "/* Container */\n.masonry-container {\n --column-count-small: 1;\n --column-count-medium: 2;\n --column-count-large: 3;\n --column-gap: 0.125rem;\n padding: var(--column-gap);\n}\n\n/* Columns */\n.masonry-columns {\n column-gap: var(--column-gap);\n column-count: var(--column-count-small);\n column-width: calc(1 / var(--column-count-small) * 100%);\n}\n\n@media only screen and (min-width: 640px) {\n .masonry-columns {\n column-count: var(--column-count-medium);\n column-width: calc(1 / var(--column-count-medium) * 100%);\n }\n}\n\n@media only screen and (min-width: 800px) {\n .masonry-columns {\n column-count: var(--column-count-large);\n column-width: calc(1 / var(--column-count-large) * 100%);\n }\n}\n\n/* Bricks */\n.masonry-brick {\n width: 100%;\n height: auto;\n margin: var(--column-gap) 0;\n display: block;\n}\n\n.masonry-brick:first-child {\n margin: 0 0 var(--column-gap);\n}",
"js": "",
"scopedCss": "[data-scope=\"masonry-layout\"] {\n /* Container */\n /* Columns */\n /* Bricks */ }\n [data-scope=\"masonry-layout\"] .masonry-container {\n --column-count-small: 1;\n --column-count-medium: 2;\n --column-count-large: 3;\n --column-gap: 0.125rem;\n padding: var(--column-gap); }\n [data-scope=\"masonry-layout\"] .masonry-columns {\n column-gap: var(--column-gap);\n column-count: var(--column-count-small);\n column-width: calc(1 / var(--column-count-small) * 100%); }\n @media only screen and (min-width: 640px) {\n [data-scope=\"masonry-layout\"] .masonry-columns {\n column-count: var(--column-count-medium);\n column-width: calc(1 / var(--column-count-medium) * 100%); } }\n @media only screen and (min-width: 800px) {\n [data-scope=\"masonry-layout\"] .masonry-columns {\n column-count: var(--column-count-large);\n column-width: calc(1 / var(--column-count-large) * 100%); } }\n [data-scope=\"masonry-layout\"] .masonry-brick {\n width: 100%;\n height: auto;\n margin: var(--column-gap) 0;\n display: block; }\n [data-scope=\"masonry-layout\"] .masonry-brick:first-child {\n margin: 0 0 var(--column-gap); }\n"
},
"tags": [
"layout",
"advanced"
]
},
"meta": {
"hash": "4bff5480f38e265090bed5d84cc8e7dc6d054570f65a168f1ccf381b19ffef48",
"firstSeen": "1576023545",
"lastUpdated": "1583441571",
"updateCount": 7,
"authorCount": 4
}
},
{
"id": "mouse-cursor-gradient-tracking",
"title": "Mouse cursor gradient tracking",
"type": "snippet",
"attributes": {
"fileName": "mouse-cursor-gradient-tracking.md",
"text": "A hover effect where the gradient follows the mouse cursor.\n\n",
"explanation": "\n\n1. `--x` and `--y` are used to track the position of the mouse on the button.\n2. `--size` is used to keep modify of the gradient's dimensions.\n3. `background: radial-gradient(circle closest-side, pink, transparent);` creates the gradient at the correct postion.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-variables\n",
"supportPercentage": 98.68
},
"codeBlocks": {
"html": "",
"css": ".mouse-cursor-gradient-tracking {\n position: relative;\n background: #7983ff;\n padding: 0.5rem 1rem;\n font-size: 1.2rem;\n border: none;\n color: white;\n cursor: pointer;\n outline: none;\n overflow: hidden;\n}\n\n.mouse-cursor-gradient-tracking span {\n position: relative;\n}\n\n.mouse-cursor-gradient-tracking::before {\n --size: 0;\n content: '';\n position: absolute;\n left: var(--x);\n top: var(--y);\n width: var(--size);\n height: var(--size);\n background: radial-gradient(circle closest-side, pink, transparent);\n transform: translate(-50%, -50%);\n transition: width 0.2s ease, height 0.2s ease;\n}\n\n.mouse-cursor-gradient-tracking:hover::before {\n --size: 200px;\n}",
"js": "var btn = document.querySelector('.mouse-cursor-gradient-tracking')\nbtn.onmousemove = function(e) {\n var rect = e.target.getBoundingClientRect()\n var x = e.clientX - rect.left\n var y = e.clientY - rect.top\n btn.style.setProperty('--x', x + 'px')\n btn.style.setProperty('--y', y + 'px')\n}",
"scopedCss": "[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking {\n position: relative;\n background: #7983ff;\n padding: 0.5rem 1rem;\n font-size: 1.2rem;\n border: none;\n color: white;\n cursor: pointer;\n outline: none;\n overflow: hidden; }\n\n[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking span {\n position: relative; }\n\n[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking::before {\n --size: 0;\n content: '';\n position: absolute;\n left: var(--x);\n top: var(--y);\n width: var(--size);\n height: var(--size);\n background: radial-gradient(circle closest-side, pink, transparent);\n transform: translate(-50%, -50%);\n transition: width 0.2s ease, height 0.2s ease; }\n\n[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking:hover::before {\n --size: 200px; }\n"
},
"tags": [
"visual",
"interactivity",
"advanced"
]
},
"meta": {
"hash": "159c33e454099f02ef387c5392aec044a5a6d67b0a56cb391d2a7a6f59e1f6d2",
"firstSeen": "1519564479",
"lastUpdated": "1583441571",
"updateCount": 18,
"authorCount": 4
}
},
{
"id": "navigation-list-item-hover-and-focus-effect",
"title": "Navigation list item hover and focus effect",
"type": "snippet",
"attributes": {
"fileName": "navigation-list-item-hover-and-focus-effect.md",
"text": "Fancy hover and focus effect at navigation items using transform CSS property.\n\n",
"explanation": "\n\n- Use the `::before` pseudo-element at the list item anchor to create a hover effect, hide it using `transform: scale(0)`.\n- Use the `:hover` and `:focus` pseudo-selectors to transition to `transform: scale(1)` and show the pseudo-element with its colored background.\n- Prevent the pseudo-element from covering the anchor element by using `z-index: -1`.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=transforms2d\n- https://caniuse.com/#feat=css-transitions\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "",
"css": "nav ul {\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: hidden;\n}\n\nnav li {\n float: left;\n}\n\nnav li a {\n position: relative;\n display: block;\n color: #222;\n text-align: center;\n padding: 8px 12px;\n text-decoration: none;\n}\n\nli a::before {\n position: absolute;\n content: \"\";\n width: 100%;\n height: 100%;\n bottom: 0;\n left: 0;\n background-color: #f6c126;\n z-index: -1;\n transform: scale(0);\n transition: transform 0.5s ease-in-out;\n}\n\nli a:hover::before,\nli a:focus::before {\n transform: scale(1);\n}",
"js": "",
"scopedCss": "[data-scope=\"navigation-list-item-hover-and-focus-effect\"] nav ul {\n list-style: none;\n margin: 0;\n padding: 0;\n overflow: hidden; }\n\n[data-scope=\"navigation-list-item-hover-and-focus-effect\"] nav li {\n float: left; }\n\n[data-scope=\"navigation-list-item-hover-and-focus-effect\"] nav li a {\n position: relative;\n display: block;\n color: #222;\n text-align: center;\n padding: 8px 12px;\n text-decoration: none; }\n\n[data-scope=\"navigation-list-item-hover-and-focus-effect\"] li a::before {\n position: absolute;\n content: \"\";\n width: 100%;\n height: 100%;\n bottom: 0;\n left: 0;\n background-color: #f6c126;\n z-index: -1;\n transform: scale(0);\n transition: transform 0.5s ease-in-out; }\n\n[data-scope=\"navigation-list-item-hover-and-focus-effect\"] li a:hover::before,\n[data-scope=\"navigation-list-item-hover-and-focus-effect\"] li a:focus::before {\n transform: scale(1); }\n"
},
"tags": [
"visual",
"beginner"
]
},
"meta": {
"hash": "081120d282bf5041a82e0fd82d1b90afb28591eaaf6c2dfb9194d23db5b8d3a4",
"firstSeen": "1568922537",
"lastUpdated": "1583441571",
"updateCount": 5,
"authorCount": 3
}
},
{
"id": "not-selector",
"title": ":not selector",
"type": "snippet",
"attributes": {
"fileName": "not-selector.md",
"text": "The `:not` pseudo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.\n\n",
"explanation": "\n\n- `li:not(:last-child)` specifies that the styles should apply to all `li` elements except the `:last-child`.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-sel3\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "\n \n
\n ",
"css": ".overflow-scroll-gradient {\n position: relative;\n}\n\n.overflow-scroll-gradient::after {\n content: '';\n position: absolute;\n bottom: 0;\n width: 250px;\n height: 25px;\n background: linear-gradient(transparent, white); \n pointer-events: none;\n}\n\n.overflow-scroll-gradient-scroller {\n overflow-y: scroll;\n background: white;\n width: 240px;\n height: 200px;\n padding: 15px;\n line-height: 1.2;\n}",
"js": "",
"scopedCss": "[data-scope=\"overflow-scroll-gradient\"] .overflow-scroll-gradient {\n position: relative; }\n\n[data-scope=\"overflow-scroll-gradient\"] .overflow-scroll-gradient::after {\n content: '';\n position: absolute;\n bottom: 0;\n width: 250px;\n height: 25px;\n background: linear-gradient(transparent, white);\n pointer-events: none; }\n\n[data-scope=\"overflow-scroll-gradient\"] .overflow-scroll-gradient-scroller {\n overflow-y: scroll;\n background: white;\n width: 240px;\n height: 200px;\n padding: 15px;\n line-height: 1.2; }\n"
},
"tags": [
"visual",
"intermediate"
]
},
"meta": {
"hash": "8803e417053172085af754a3a63531c33cbf78f2c1a7c95a6e392be2adf9551a",
"firstSeen": "1519564479",
"lastUpdated": "1583441571",
"updateCount": 19,
"authorCount": 5
}
},
{
"id": "popout-menu",
"title": "Popout menu",
"type": "snippet",
"attributes": {
"fileName": "popout-menu.md",
"text": "Reveals an interactive popout menu on hover and focus.\n\n",
"explanation": "\n\n1. `position: relative` on the reference parent establishes a Cartesian positioning context for its child.\n2. `position: absolute` takes the popout menu out of the flow of the document and positions it in relation to the parent.\n3. `left: 100%` moves the the popout menu 100% of its parent's width from the left.\n4. `visibility: hidden` hides the popout menu initially and allows for transitions (unlike `display: none`).\n5. `.reference:hover > .popout-menu` means that when `.reference` is hovered over, select immediate children with a class of `.popout-menu` and change their `visibility` to `visible`, which shows the popout.\n6. `.reference:focus > .popout-menu` means that when `.reference` is focused, the popout would be shown.\n7. `.reference:focus-within > .popout-menu` ensures that the popout is shown when the focus is _within_ the reference.\n\n",
"browserSupport": {
"text": "\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "\n Lorem ipsum dolor sit amet consectetur adipisicing elit. \n\n Iure id exercitationem nulla qui repellat laborum vitae, \n molestias tempora velit natus. Quas, assumenda nisi. \n Quisquam enim qui iure, consequatur velit sit? \n Lorem ipsum dolor sit amet consectetur adipisicing elit. \n Iure id exercitationem nulla qui repellat laborum vitae, \n molestias tempora velit natus. Quas, assumenda nisi. \n Quisquam enim qui iure, consequatur velit sit?\n ",
"css": ".reference {\n position: relative;\n background: tomato;\n width: 100px;\n height: 100px;\n}\n\n.popout-menu {\n position: absolute;\n visibility: hidden;\n left: 100%;\n background: #333;\n color: white;\n padding: 15px;\n}\n\n.reference:hover > .popout-menu,\n.reference:focus > .popout-menu,\n.reference:focus-within > .popout-menu {\n visibility: visible;\n}",
"js": "",
"scopedCss": "[data-scope=\"popout-menu\"] .reference {\n position: relative;\n background: tomato;\n width: 100px;\n height: 100px; }\n\n[data-scope=\"popout-menu\"] .popout-menu {\n position: absolute;\n visibility: hidden;\n left: 100%;\n background: #333;\n color: white;\n padding: 15px; }\n\n[data-scope=\"popout-menu\"] .reference:hover > .popout-menu,\n[data-scope=\"popout-menu\"] .reference:focus > .popout-menu,\n[data-scope=\"popout-menu\"] .reference:focus-within > .popout-menu {\n visibility: visible; }\n"
},
"tags": [
"interactivity",
"intermediate"
]
},
"meta": {
"hash": "4103e63398b3bc9f646ff4e528ff28aad8b10d666b541254575eb257af43311b",
"firstSeen": "1519564479",
"lastUpdated": "1583441571",
"updateCount": 13,
"authorCount": 5
}
},
{
"id": "pretty-text-underline",
"title": "Pretty text underline",
"type": "snippet",
"attributes": {
"fileName": "pretty-text-underline.md",
"text": "A nicer alternative to `text-decoration: underline` where descenders do not clip the underline.\nNatively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline.\n\n",
"explanation": "\n\n1. `text-shadow` uses 4 values with offsets that cover a 4x4 px area to ensure the underline has a \"thick\" shadow that covers the line where descenders clip it. Use a color that matches the background. For a larger font, use a larger `px` size. Additional values can create an even thicker shadow, and subpixel values can also be used.\n2. `background-image: linear-gradient(...)` creates a 90deg gradient using the text color (`currentColor`).\n3. The `background-*` properties size the gradient as 100% of the width of the block and 1px in height at the bottom and disables repetition, which creates a 1px underline beneath the text.\n4. The `::selection` pseudo selector rule ensures the text shadow does not interfere with text selection.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-textshadow\n- https://caniuse.com/#feat=css-gradients\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": " Pretty text underline without clipping descending letters. ", "css": ".pretty-text-underline {\n display: inline;\n text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;\n background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);\n background-position: bottom;\n background-repeat: no-repeat;\n background-size: 100% 1px;\n}\n\n.pretty-text-underline::-moz-selection {\n background-color: rgba(0, 150, 255, 0.3);\n text-shadow: none;\n}\n\n.pretty-text-underline::selection {\n background-color: rgba(0, 150, 255, 0.3);\n text-shadow: none;\n}", "js": "", "scopedCss": "[data-scope=\"pretty-text-underline\"] .pretty-text-underline {\n display: inline;\n text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;\n background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);\n background-position: bottom;\n background-repeat: no-repeat;\n background-size: 100% 1px; }\n\n[data-scope=\"pretty-text-underline\"] .pretty-text-underline::-moz-selection {\n background-color: rgba(0, 150, 255, 0.3);\n text-shadow: none; }\n\n[data-scope=\"pretty-text-underline\"] .pretty-text-underline::selection {\n background-color: rgba(0, 150, 255, 0.3);\n text-shadow: none; }\n" }, "tags": [ "visual", "intermediate" ] }, "meta": { "hash": "8e513bfd8e3e72d073e2411fd903a978178c5dcf8b5aa8e603dc653dbba293d6", "firstSeen": "1519564479", "lastUpdated": "1583441571", "updateCount": 19, "authorCount": 6 } }, { "id": "pulse-loader", "title": "Pulse loader", "type": "snippet", "attributes": { "fileName": "pulse-loader.md", "text": "Creates a pulse effect loader animation using the `animation-delay` property.\n\n", "explanation": "\n\n- Use `@keyframes` to define an animation at two points in the cycle, start (`0%`), where the two `` elements have no `width` or `height` and are positioned at the center and end (`100%`), where both ` ` elements have increased `width` and `height`, but their `position` is reset to `0`.\n- Use `opacity` to transition from `1` to `0` when animating to give the ` ` elements a disappearing effect as they expand.\n- `.ripple-loader`, which is the parent container, has a predefined `width` and `height`. It uses `position: relative` to position its children.\n- Use `animation-delay` on the second ` ` element, so that each element starts its animation at a different time.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-animation\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": " \n \n \n ",
"css": ".ripple-loader {\n position: relative;\n width: 64px;\n height: 64px;\n}\n\n.ripple-loader div {\n position: absolute;\n border: 4px solid #76ff03;\n border-radius: 50%;\n animation: ripple-loader 1s ease-out infinite;\n}\n\n.ripple-loader div:nth-child(2) {\n animation-delay: -0.5s;\n}\n\n@keyframes ripple-loader {\n 0% {\n top: 32px;\n left: 32px;\n width: 0;\n height: 0;\n opacity: 1;\n }\n 100% {\n top: 0;\n left: 0;\n width: 64px;\n height: 64px;\n opacity: 0;\n }\n}",
"js": "",
"scopedCss": "[data-scope=\"pulse-loader\"] .ripple-loader {\n position: relative;\n width: 64px;\n height: 64px; }\n\n[data-scope=\"pulse-loader\"] .ripple-loader div {\n position: absolute;\n border: 4px solid #76ff03;\n border-radius: 50%;\n animation: ripple-loader 1s ease-out infinite; }\n\n[data-scope=\"pulse-loader\"] .ripple-loader div:nth-child(2) {\n animation-delay: -0.5s; }\n\n@keyframes ripple-loader {\n 0% {\n top: 32px;\n left: 32px;\n width: 0;\n height: 0;\n opacity: 1; }\n 100% {\n top: 0;\n left: 0;\n width: 64px;\n height: 64px;\n opacity: 0; } }\n"
},
"tags": [
"animation",
"beginner"
]
},
"meta": {
"hash": "11f0b0631cb97ab53a144c263648c155527e570e0ceefaea59201c39de73b57b",
"firstSeen": "1570274976",
"lastUpdated": "1570335973",
"updateCount": 4,
"authorCount": 3
}
},
{
"id": "reset-all-styles",
"title": "Reset all styles",
"type": "snippet",
"attributes": {
"fileName": "reset-all-styles.md",
"text": "Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties.\n\n",
"explanation": "\n\n- The `all` property allows you to reset all styles (inherited or not) to default values.\n\n",
"browserSupport": {
"text": "\n\n⚠️ MS Edge status is under consideration.\n\n- https://caniuse.com/#feat=css-all\n",
"supportPercentage": 97.45
},
"codeBlocks": {
"html": "\n ",
"css": ".reset-all-styles {\n all: initial;\n}",
"js": "",
"scopedCss": "[data-scope=\"reset-all-styles\"] .reset-all-styles {\n all: initial; }\n"
},
"tags": [
"visual",
"beginner"
]
},
"meta": {
"hash": "f9542b2db5cd49f09e53b3af8348c58c973244bdeede87857e49660c6e713d65",
"firstSeen": "1519847496",
"lastUpdated": "1583441571",
"updateCount": 14,
"authorCount": 5
}
},
{
"id": "shape-separator",
"title": "Shape separator",
"type": "snippet",
"attributes": {
"fileName": "shape-separator.md",
"text": "Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.\n\n",
"explanation": "\n\n1. `position: relative` on the element establishes a Cartesian positioning context for pseudo elements.\n2. `::after` defines a pseudo element.\n3. `background-image: url(...)` adds the SVG shape (a 24x12 triangle) as the background image of the pseudo element, which repeats by default. It must be the same color as the block that is being separated. For other shapes, we can use [the URL-encoder for SVG](http://yoksel.github.io/url-encoder/).\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 100%` ensures the element stretches the entire width of its parent.\n6. `height: 12px` is the same height as the shape.\n7. `bottom: 0` positions the pseudo element at the bottom of the parent.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=svg\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "",
"css": ".shape-separator {\n position: relative;\n height: 48px;\n background: #333;\n}\n\n.shape-separator::after {\n content: '';\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='m12 0l12 12h-24z' fill='%23fff'/%3E%3C/svg%3E\");\n position: absolute;\n width: 100%;\n height: 12px;\n bottom: 0;\n}",
"js": "",
"scopedCss": "[data-scope=\"shape-separator\"] .shape-separator {\n position: relative;\n height: 48px;\n background: #333; }\n\n[data-scope=\"shape-separator\"] .shape-separator::after {\n content: '';\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='m12 0l12 12h-24z' fill='%23fff'/%3E%3C/svg%3E\");\n position: absolute;\n width: 100%;\n height: 12px;\n bottom: 0; }\n"
},
"tags": [
"visual",
"intermediate"
]
},
"meta": {
"hash": "b14f91e079c09e854ee0579eed3246c792794fb8d1b27deb6bec15df23f24917",
"firstSeen": "1519564479",
"lastUpdated": "1583441571",
"updateCount": 14,
"authorCount": 5
}
},
{
"id": "sibling-fade",
"title": "Sibling fade",
"type": "snippet",
"attributes": {
"fileName": "sibling-fade.md",
"text": "Fades out the siblings of a hovered item.\n\n",
"explanation": "\n\n1. `transition: opacity 0.2s` specifies that changes to opacity will be transitioned over 0.2 seconds.\n2. `.sibling-fade:hover span:not(:hover)` specifies that when the parent is hovered, select any `span` children that are not currently being hovered and change their opacity to `0.5`.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-sel3\n- https://caniuse.com/#feat=css-transitions\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "Title\n\n Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui\n repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui\n iure, consequatur velit sit?\n \n\n Item 1 Item 2 Item 3 Item 4\n Item 5 Item 6\n ",
"css": "span {\n padding: 0 1rem;\n transition: opacity 0.2s;\n}\n\n.sibling-fade:hover span:not(:hover) {\n opacity: 0.5;\n}",
"js": "",
"scopedCss": "[data-scope=\"sibling-fade\"] span {\n padding: 0 1rem;\n transition: opacity 0.2s; }\n\n[data-scope=\"sibling-fade\"] .sibling-fade:hover span:not(:hover) {\n opacity: 0.5; }\n"
},
"tags": [
"interactivity",
"intermediate"
]
},
"meta": {
"hash": "35bfb52929dcbd21c120d555c9d3382154f47b661d31722ffb3d21281021bba3",
"firstSeen": "1520237843",
"lastUpdated": "1583441571",
"updateCount": 13,
"authorCount": 4
}
},
{
"id": "staggered-animation",
"title": "Staggered animation",
"type": "snippet",
"attributes": {
"fileName": "staggered-animation.md",
"text": "Creates a staggered animation for the elements of a list.\n\n",
"explanation": "\n\n- Set the `opacity` to `0` and `transform` to `translateX(100%)` to make list elements transparent and move them all the way to the right.\n- Specify the appropriate `transition` properties for list elements, except `transition-delay` which is specified relative to the `--i` custom property.\n- Use inline styles to specify a value for `--i` for each list element, which will in turn be used for `transition-delay` to create the stagger effect.\n- Use the `:checked` selector for the checkbox to appropriately style list elements, setting `opacity` to `1` and `transform` to `translateX(0)` to make them appear and slide into view.\n\n",
"browserSupport": {
"text": "\n\n- https://caniuse.com/#feat=css-variables\n- https://caniuse.com/#feat=css-transitions\n",
"supportPercentage": 98.68
},
"codeBlocks": {
"html": "\n \n \n \n ",
"css": ".container {\n overflow-x: hidden;\n width: 100%;\n}\n\n.menu-toggler {\n display: none;\n}\n\n.menu-toggler-label {\n cursor: pointer;\n font-size: 20px;\n font-weight: bold;\n}\n\n.stagger-menu {\n list-style-type: none;\n margin: 16px 0;\n padding: 0;\n}\n\n.stagger-menu li {\n margin-bottom: 8px;\n font-size: 18px;\n opacity: 0;\n transform: translateX(100%);\n transition-property: opacity, transform;\n transition-duration: 0.3s;\n transition-timing-function: cubic-bezier(0.750, -0.015, 0.565, 1.055);\n}\n\n.menu-toggler:checked ~ .stagger-menu li {\n opacity: 1;\n transform: translateX(0);\n transition-delay: calc(0.055s * var(--i));\n}",
"js": "",
"scopedCss": "[data-scope=\"staggered-animation\"] .container {\n overflow-x: hidden;\n width: 100%; }\n\n[data-scope=\"staggered-animation\"] .menu-toggler {\n display: none; }\n\n[data-scope=\"staggered-animation\"] .menu-toggler-label {\n cursor: pointer;\n font-size: 20px;\n font-weight: bold; }\n\n[data-scope=\"staggered-animation\"] .stagger-menu {\n list-style-type: none;\n margin: 16px 0;\n padding: 0; }\n\n[data-scope=\"staggered-animation\"] .stagger-menu li {\n margin-bottom: 8px;\n font-size: 18px;\n opacity: 0;\n transform: translateX(100%);\n transition-property: opacity, transform;\n transition-duration: 0.3s;\n transition-timing-function: cubic-bezier(0.75, -0.015, 0.565, 1.055); }\n\n[data-scope=\"staggered-animation\"] .menu-toggler:checked ~ .stagger-menu li {\n opacity: 1;\n transform: translateX(0);\n transition-delay: calc(0.055s * var(--i)); }\n"
},
"tags": [
"animation",
"advanced"
]
},
"meta": {
"hash": "b1dc6f9fcc5cc91b59e89864b568048040e1879b2fc165d580cd21bc3fb73e50",
"firstSeen": "1584353945",
"lastUpdated": "1584353945",
"updateCount": 2,
"authorCount": 2
}
},
{
"id": "system-font-stack",
"title": "System font stack",
"type": "snippet",
"attributes": {
"fileName": "system-font-stack.md",
"text": "Uses the native font of the operating system to get close to a native app feel.\n\n",
"explanation": "\n\nThe browser looks for each successive font, preferring the first one if possible, and falls back to the next if it cannot find the font (on the system or defined in CSS).\n\n1. `-apple-system` is San Francisco, used on iOS and macOS (not Chrome however)\n2. `BlinkMacSystemFont` is San Francisco, used on macOS Chrome\n3. `Segoe UI` is used on Windows 10\n4. `Roboto` is used on Android\n5. `Oxygen-Sans` is used on Linux with KDE\n6. `Ubuntu` is used on Ubuntu (all variants)\n7. `Cantarell` is used on Linux with GNOME Shell\n8. `\"Helvetica Neue\"` and `Helvetica` is used on macOS 10.10 and below (wrapped in quotes because it has a space)\n9. `Arial` is a font widely supported by all operating systems\n10. `sans-serif` is the fallback sans-serif font if none of the other fonts are supported\n\n",
"browserSupport": {
"text": "\n",
"supportPercentage": 100
},
"codeBlocks": {
"html": "This text uses the system font. ", "css": ".system-font-stack {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,\n Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif;\n}", "js": "", "scopedCss": "[data-scope=\"system-font-stack\"] .system-font-stack {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif; }\n" }, "tags": [ "visual", "beginner" ] }, "meta": { "hash": "be5f2dfdc4cd4cafea8fbe197e22b1df40a40e10b61c17ea86af2b4f72bba127", "firstSeen": "1519564479", "lastUpdated": "1583441571", "updateCount": 13, "authorCount": 6 } }, { "id": "tile-layout-using-inline-block", "title": "3-tile layout", "type": "snippet", "attributes": { "fileName": "tile-layout-using-inline-block.md", "text": "Align items horizontally using `display: inline-block` to create a 3-tile layout.\n\n", "explanation": "\n\n- Use `display: inline-block` to create a tiled layout, without using `float`, `flex` or `grid`.\n- `.tiles` is the container component, `.tile` is an item that needs to be displayed inline.\n- Use `width: calc((900px / 3))` to divide the width of the container evenly into 3 columns.\n- Set `font-size: 0;` on `.tiles` to avoid whitespace.\n- Set `font-size: 20px` to `h2` in order to display the text.\n\n", "browserSupport": { "text": "\n\n- https://www.caniuse.com/#search=inline-block\n", "supportPercentage": 100 }, "codeBlocks": { "html": "\n ",
"css": ".tiles {\n width: 900px;\n font-size: 0;\n}\n\n.tile {\n width: calc(900px / 3);\n display: inline-block;\n}\n\n.tile h2 {\n font-size: 20px;\n}",
"js": "",
"scopedCss": "[data-scope=\"tile-layout-using-inline-block\"] .tiles {\n width: 900px;\n font-size: 0; }\n\n[data-scope=\"tile-layout-using-inline-block\"] .tile {\n width: calc(900px / 3);\n display: inline-block; }\n\n[data-scope=\"tile-layout-using-inline-block\"] .tile h2 {\n font-size: 20px; }\n"
},
"tags": [
"layout",
"beginner"
]
},
"meta": {
"hash": "ba4688945c309db9b6255f4555299034a67ea583e4e8db2806085c1c257b736f",
"firstSeen": "1569999119",
"lastUpdated": "1569999119",
"updateCount": 2,
"authorCount": 2
}
},
{
"id": "toggle-switch",
"title": "Toggle switch",
"type": "snippet",
"attributes": {
"fileName": "toggle-switch.md",
"text": "Creates a toggle switch with CSS only.\n\n",
"explanation": "\n\nThis effect is styling only the `\n \n 30 Seconds of CSS\n\n \n 30 Seconds of CSS\n\n \n30 Seconds of CSS\n |