diff --git a/snippets/bouncing-loader.md b/snippets/bouncing-loader.md index 321b9f0dc..067e5bd55 100644 --- a/snippets/bouncing-loader.md +++ b/snippets/bouncing-loader.md @@ -20,10 +20,12 @@ Creates a bouncing loader animation. transform: translate3d(0, -1rem, 0); } } + .bouncing-loader { display: flex; justify-content: center; } + .bouncing-loader > div { width: 1rem; height: 1rem; @@ -32,9 +34,11 @@ Creates a bouncing loader animation. border-radius: 50%; animation: bouncing-loader 0.6s infinite alternate; } + .bouncing-loader > div:nth-child(2) { animation-delay: 0.2s; } + .bouncing-loader > div:nth-child(3) { animation-delay: 0.4s; } diff --git a/snippets/box-sizing-reset.md b/snippets/box-sizing-reset.md index 5be53d0f5..073f28604 100644 --- a/snippets/box-sizing-reset.md +++ b/snippets/box-sizing-reset.md @@ -1,6 +1,6 @@ --- title: Box-sizing reset -tags: layout +tags: layout,beginner --- Resets the box-model so that `width`s and `height`s are not affected by their `border`s or `padding`. @@ -14,11 +14,13 @@ Resets the box-model so that `width`s and `height`s are not affected by their `b html { box-sizing: border-box; } + *, *::before, *::after { box-sizing: inherit; } + .box { display: inline-block; width: 150px; @@ -28,6 +30,7 @@ html { color: white; border: 10px solid red; } + .content-box { box-sizing: content-box; } diff --git a/snippets/button-border-animation.md b/snippets/button-border-animation.md index 830b312b1..4a975d52f 100644 --- a/snippets/button-border-animation.md +++ b/snippets/button-border-animation.md @@ -1,6 +1,6 @@ --- title: Button border animation -tags: animation +tags: animation,intermediate --- Creates a border animation on hover. @@ -18,6 +18,7 @@ Creates a border animation on hover. padding: 12px 40px 10px; position: relative; } + .button:before, .button:after { border: 0 solid transparent; @@ -27,19 +28,23 @@ Creates a border animation on hover. position: absolute; width: 24px; } + .button:before { border-top: 2px solid #c47135; left: 0px; top: -5px; } + .button:after { border-bottom: 2px solid #c47135; bottom: -5px; right: 0px; } + .button:hover { background-color: #c47135; } + .button:hover:before, .button:hover:after { height: 100%; @@ -49,6 +54,6 @@ Creates a border animation on hover. #### Explanation -- Use the `:before` and `:after` pseduo-elements as borders that animate on hover. +- Use the `:before` and `:after` pseudo-elements as borders that animate on hover. #### Browser support diff --git a/snippets/circle.md b/snippets/circle.md index b91d1ab25..2b60e326c 100644 --- a/snippets/circle.md +++ b/snippets/circle.md @@ -1,6 +1,6 @@ --- title: Circle -tags: visual +tags: visual,beginner --- Creates a circle shape with pure CSS. diff --git a/snippets/clearfix.md b/snippets/clearfix.md index 010f9a736..f5f39f667 100644 --- a/snippets/clearfix.md +++ b/snippets/clearfix.md @@ -1,6 +1,6 @@ --- title: Clearfix -tags: layout +tags: layout,beginner --- Ensures that an element self-clears its children. diff --git a/snippets/constant-width-to-height-ratio.md b/snippets/constant-width-to-height-ratio.md index e8007e895..72188c890 100644 --- a/snippets/constant-width-to-height-ratio.md +++ b/snippets/constant-width-to-height-ratio.md @@ -3,8 +3,7 @@ title: Constant width to height ratio tags: layout --- -Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion -(i.e., its width to height ratio remains constant). +Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion (i.e. its width to height ratio remains constant). ```html
@@ -15,11 +14,13 @@ Given an element of variable width, it will ensure its height remains proportion background: #333; width: 50%; } + .constant-width-to-height-ratio::before { content: ''; padding-top: 100%; float: left; } + .constant-width-to-height-ratio::after { content: ''; display: block; diff --git a/snippets/counter.md b/snippets/counter.md index 000e612da..eee6a55cd 100644 --- a/snippets/counter.md +++ b/snippets/counter.md @@ -1,6 +1,6 @@ --- title: Counter -tags: visual, other +tags: visual,advanced --- Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used. @@ -33,12 +33,12 @@ li::before { #### Explanation -- You can create a ordered list using any type of HTML. +You can create a ordered list using any type of HTML. -1. `counter-reset` Initializes a counter, the value is the name of the counter. By default, the counter starts at 0. This property can also be used to change its value to any specific number. -2. `counter-increment` Used in element that will be countable. Once `counter-reset` initialized, a counter's value can be increased or decreased. -3. `counter(name, style)` Displays the value of a section counter. Generally used in a `content` property. This function can receive two parameters, the first as the name of the counter and the second one can be `decimal` or `upper-roman` (`decimal` by default). -4. `counters(counter, string, style)` Displays the value of a section counter. Generally used in a `content` property. This function can receive three parameters, the first as the name of the counter, the second one you can include a string which comes after the counter and the third one can be `decimal` or `upper-roman` (`decimal` by default). +1. `counter-reset` is used to initialize a counter, the name of which is the value of the attribute. By default, the counter starts at `0`. This property can also be used to change its value to any specific number. +2. `counter-increment` is used for an element that will be countable. Once `counter-reset` is initialized, a counter's value can be increased or decreased. +3. `counter(name, style)` displays the value of a section counter. Generally used with the `content` property. This function can receive two parameters, the first being the name of the counter and the second one either `decimal` or `upper-roman` (`decimal` by default). +4. `counters(counter, string, style)` displays the value of a section counter. Generally used with the `content` property. This function can receive three parameters, the first as the name of the counter, the second one you can include a string which comes after the counter and the third one can be `decimal` or `upper-roman` (`decimal` by default). 5. A CSS counter can be especially useful for making outlined lists, because a new instance of the counter is automatically created in child elements. Using the `counters()` function, separating text can be inserted between different levels of nested counters. #### Browser support diff --git a/snippets/custom-scrollbar.md b/snippets/custom-scrollbar.md index 4c8f0a4ef..dfbce08aa 100644 --- a/snippets/custom-scrollbar.md +++ b/snippets/custom-scrollbar.md @@ -1,6 +1,6 @@ --- title: Custom scrollbar -tags: visual +tags: visual,advanced --- Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms. diff --git a/snippets/custom-text-selection.md b/snippets/custom-text-selection.md index bcdcd19d6..256aef623 100644 --- a/snippets/custom-text-selection.md +++ b/snippets/custom-text-selection.md @@ -1,6 +1,6 @@ --- title: Custom text selection -tags: visual +tags: visual,beginner --- Changes the styling of text selection. @@ -14,6 +14,7 @@ Changes the styling of text selection. background: aquamarine; color: black; } + .custom-text-selection::selection { background: deeppink; color: white; @@ -26,7 +27,6 @@ Changes the styling of text selection. #### Browser support -⚠️ Requires prefixes for full support and is not actually -in any specification. +⚠️ Requires prefixes for full support and is not actually in any specification. - https://caniuse.com/#feat=css-selection diff --git a/snippets/disable-selection.md b/snippets/disable-selection.md index 81218ee9b..90b2f9c4f 100644 --- a/snippets/disable-selection.md +++ b/snippets/disable-selection.md @@ -1,6 +1,6 @@ --- title: Disable selection -tags: interactivity +tags: interactivity,beginner --- Makes the content unselectable. @@ -20,10 +20,8 @@ Makes the content unselectable. - `user-select: none` specifies that the text cannot be selected. +_Note: This is not a secure method to prevent users from copying content._ + #### Browser support -⚠️ Requires prefixes for full support. -
-⚠️ This is not a secure method to prevent users from copying content. - - https://caniuse.com/#feat=user-select-none diff --git a/snippets/display-table-centering.md b/snippets/display-table-centering.md index d06c127c2..ba1876696 100644 --- a/snippets/display-table-centering.md +++ b/snippets/display-table-centering.md @@ -1,6 +1,6 @@ --- title: Display table centering -tags: layout +tags: layout,intermediate --- Vertically and horizontally centers a child element within its parent element using `display: table` (as an alternative to `flexbox`). diff --git a/snippets/donut-spinner.md b/snippets/donut-spinner.md index ddac6e6c5..cc2d9ae8f 100644 --- a/snippets/donut-spinner.md +++ b/snippets/donut-spinner.md @@ -1,6 +1,6 @@ --- title: Donut spinner -tags: animation +tags: animation,intermediate --- Creates a donut spinner that can be used to indicate the loading of content. @@ -18,6 +18,7 @@ Creates a donut spinner that can be used to indicate the loading of content. transform: rotate(360deg); } } + .donut { display: inline-block; border: 4px solid rgba(0, 0, 0, 0.1); @@ -35,7 +36,5 @@ Creates a donut spinner that can be used to indicate the loading of content. #### Browser support -⚠️ Requires prefixes for full support. - - https://caniuse.com/#feat=css-animation - https://caniuse.com/#feat=transforms2d diff --git a/snippets/dynamic-shadow.md b/snippets/dynamic-shadow.md index 26d5dfc5c..4709e1a6c 100644 --- a/snippets/dynamic-shadow.md +++ b/snippets/dynamic-shadow.md @@ -1,6 +1,6 @@ --- title: Dynamic shadow -tags: visual +tags: visual,intermediate --- Creates a shadow similar to `box-shadow` but based on the colors of the element itself. @@ -17,6 +17,7 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element background: linear-gradient(75deg, #6d78ff, #00ffb8); z-index: 1; } + .dynamic-shadow::after { content: ''; width: 100%; @@ -45,6 +46,4 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element #### Browser support -⚠️ Requires prefixes for full support. - - https://caniuse.com/#feat=css-filters diff --git a/snippets/easing-variables.md b/snippets/easing-variables.md index e98a0261d..4a7dc8825 100644 --- a/snippets/easing-variables.md +++ b/snippets/easing-variables.md @@ -1,10 +1,9 @@ --- title: Easing variables -tags: animation +tags: animation,beginner --- -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`. +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`. ```html
Hover
diff --git a/snippets/etched-text.md b/snippets/etched-text.md index 627e9db42..4611ed62b 100644 --- a/snippets/etched-text.md +++ b/snippets/etched-text.md @@ -1,6 +1,6 @@ --- title: Etched text -tags: visual +tags: visual,intermediate --- Creates an effect where text appears to be "etched" or engraved into the background. diff --git a/snippets/evenly-distributed-children.md b/snippets/evenly-distributed-children.md index 659c07582..62282e80c 100644 --- a/snippets/evenly-distributed-children.md +++ b/snippets/evenly-distributed-children.md @@ -1,6 +1,6 @@ --- title: Evenly distributed children -tags: layout +tags: layout,intermediate --- Evenly distributes child elements within a parent element. @@ -25,10 +25,8 @@ Evenly distributes child elements within a parent element. 1. `display: flex` enables flexbox. 2. `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. -- Alternatively, use `justify-content: space-around` to distribute the children with space around them, rather than between them. +_Note: Alternatively, use `justify-content: space-around` to distribute the children with space around them, rather than between them._ #### Browser support -⚠️ Needs prefixes for full support. - - https://caniuse.com/#feat=flexbox diff --git a/snippets/flexbox-centering.md b/snippets/flexbox-centering.md index 63a614f83..8af0e933b 100644 --- a/snippets/flexbox-centering.md +++ b/snippets/flexbox-centering.md @@ -1,6 +1,6 @@ --- title: Flexbox centering -tags: layout +tags: layout,beginner --- Horizontally and vertically centers a child element within a parent element using `flexbox`. @@ -20,12 +20,10 @@ Horizontally and vertically centers a child element within a parent element usin #### Explanation -1. `display: flex` enables flexbox. +1. `display: flex` creates a flexbox layout. 2. `justify-content: center` centers the child horizontally. 3. `align-items: center` centers the child vertically. #### Browser support -⚠️ Needs prefixes for full support. - - https://caniuse.com/#feat=flexbox diff --git a/snippets/focus-within.md b/snippets/focus-within.md index a008d0de0..7a127a8d4 100644 --- a/snippets/focus-within.md +++ b/snippets/focus-within.md @@ -1,6 +1,6 @@ --- title: Focus Within -tags: visual, interactivity +tags: visual,interactivity,intermediate --- Changes the appearance of a form if any of its children are focused. @@ -27,8 +27,6 @@ form:focus-within { } ``` - - #### Explanation - The psuedo class `:focus-within` applies styles to a parent element if any child element gets focused. For example, an `input` element inside a `form` element. @@ -37,7 +35,4 @@ form:focus-within { ⚠️ Not supported in IE11 or the current version of Edge. - - - https://caniuse.com/#feat=css-focus-within diff --git a/snippets/fullscreen.md b/snippets/fullscreen.md index fa7c9f711..ab11ba0d3 100644 --- a/snippets/fullscreen.md +++ b/snippets/fullscreen.md @@ -1,9 +1,9 @@ --- title: Fullscreen -tags: visual +tags: visual,advanced --- -The :fullscreen CSS pseudo-class represents an element that's displayed when the browser is in fullscreen mode. +The `:fullscreen` CSS pseudo-element represents an element that's displayed when the browser is in fullscreen mode. ```html
@@ -49,7 +49,7 @@ The :fullscreen CSS pseudo-class represents an element that's displayed when the #### Explanation -1. `fullscreen` CSS pseudo-class selector is used to select and style an element that is being displayed in fullscreen mode. +- `:fullscreen` CSS pseudo-element selector is used to select and style an element that is being displayed in fullscreen mode. #### Browser support diff --git a/snippets/ghost-trick.md b/snippets/ghost-trick.md index 6e1bb1b8b..3cca8ed2b 100644 --- a/snippets/ghost-trick.md +++ b/snippets/ghost-trick.md @@ -1,6 +1,6 @@ --- title: Ghost trick -tags: layout +tags: layout,intermediate --- Vertically centers an element in another. diff --git a/snippets/gradient-text.md b/snippets/gradient-text.md index 20bd984d9..cdf8fc232 100644 --- a/snippets/gradient-text.md +++ b/snippets/gradient-text.md @@ -1,6 +1,6 @@ --- title: Gradient text -tags: visual +tags: visual,intermediate --- Gives text a gradient color. diff --git a/snippets/grid-centering.md b/snippets/grid-centering.md index 5418c4123..4177c03c9 100644 --- a/snippets/grid-centering.md +++ b/snippets/grid-centering.md @@ -1,12 +1,14 @@ --- title: Grid centering -tags: layout +tags: layout,beginner --- Horizontally and vertically centers a child element within a parent element using `grid`. ```html -
Centered content.
+
+
Centered content.
+
``` ```css @@ -20,7 +22,7 @@ Horizontally and vertically centers a child element within a parent element usin #### Explanation -1. `display: grid` enables grid. +1. `display: grid` creates a grid layout 2. `justify-content: center` centers the child horizontally. 3. `align-items: center` centers the child vertically. diff --git a/snippets/hairline-border.md b/snippets/hairline-border.md index b433f081b..11ca9d175 100644 --- a/snippets/hairline-border.md +++ b/snippets/hairline-border.md @@ -1,10 +1,9 @@ --- title: Hairline border -tags: visual +tags: visual,advanced --- -Gives an element a border equal to 1 native device pixel in width, which can look -very sharp and crisp. +Gives an element a border equal to 1 native device pixel in width, which can look very sharp and crisp. ```html
text
@@ -36,7 +35,7 @@ very sharp and crisp. #### Explanation -1. `box-shadow`, when only using spread, adds a pseudo-border which can use subpixels\*. +1. `box-shadow`, when only using spread, adds a pseudo-border which can use subpixels \*. 2. 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`. #### Browser Support @@ -46,6 +45,6 @@ very sharp and crisp. - https://caniuse.com/#feat=css-boxshadow - https://caniuse.com/#feat=css-media-resolution -
+
-\*Chrome does not support subpixel values on `border`. Safari does not support subpixel values on `box-shadow`. Firefox supports subpixel values on both. +\* Chrome does not support subpixel values on `border`. Safari does not support subpixel values on `box-shadow`. Firefox supports subpixel values on both. diff --git a/snippets/height-transition.md b/snippets/height-transition.md index 7689e3211..ae8065133 100644 --- a/snippets/height-transition.md +++ b/snippets/height-transition.md @@ -1,6 +1,6 @@ --- title: Height transition -tags: animation +tags: animation,intermediate --- Transitions an element's height from `0` to `auto` when its height is unknown. @@ -37,7 +37,7 @@ el.style.setProperty('--max-height', height + 'px') 3. `max-height: 0` specifies that the element has no height initially. 4. `.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. ---- +
1. `el.scrollHeight` is the height of the element including overflow, which will change dynamically based on the content of the element. 2. `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. @@ -45,10 +45,7 @@ el.style.setProperty('--max-height', height + 'px') #### Browser Support
Requires JavaScript
- - ⚠️ 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. - +⚠️ 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. - https://caniuse.com/#feat=css-variables - https://caniuse.com/#feat=css-transitions diff --git a/snippets/hover-shadow-box-animation.md b/snippets/hover-shadow-box-animation.md index a89b76433..4cb17ddb8 100644 --- a/snippets/hover-shadow-box-animation.md +++ b/snippets/hover-shadow-box-animation.md @@ -1,6 +1,6 @@ --- title: Hover shadow box animation -tags: animation +tags: animation,intermediate --- Creates a shadow box around the text when it is hovered. @@ -19,6 +19,7 @@ Creates a shadow box around the text when it is hovered. transition-duration: 0.3s; transition-property: box-shadow, transform; } + .hover-shadow-box-animation:hover, .hover-shadow-box-animation:focus, .hover-shadow-box-animation:active { diff --git a/snippets/hover-underline-animation.md b/snippets/hover-underline-animation.md index 522e9468c..a675a49b3 100644 --- a/snippets/hover-underline-animation.md +++ b/snippets/hover-underline-animation.md @@ -1,12 +1,10 @@ --- title: Hover underline animation -tags: animation +tags: animation,advanced --- Creates an animated underline effect when the text is hovered over. -**Credit:** https://flatuicolors.com/ - ```html

Hover this text to see the effect!

``` @@ -17,6 +15,7 @@ Creates an animated underline effect when the text is hovered over. position: relative; color: #0087ca; } + .hover-underline-animation::after { content: ''; position: absolute; @@ -29,6 +28,7 @@ Creates an animated underline effect when the text is hovered over. transform-origin: bottom right; transition: transform 0.25s ease-out; } + .hover-underline-animation:hover::after { transform: scaleX(1); transform-origin: bottom left; diff --git a/snippets/last-item-with-remaining-available-height.md b/snippets/last-item-with-remaining-available-height.md index eb3060aae..e403eedeb 100644 --- a/snippets/last-item-with-remaining-available-height.md +++ b/snippets/last-item-with-remaining-available-height.md @@ -1,6 +1,6 @@ --- title: Last item with remaining available height -tags: layout +tags: layout,intermediate --- Take advantage of available viewport space by giving the last element the remaining available space in current viewport, even when resizing the window. @@ -34,15 +34,13 @@ body { #### Explanation -1. `height: 100%` set the height of container as viewport height. -2. `display: flex` enables flexbox. +1. `height: 100%` sets the height of container as viewport height. +2. `display: flex` creates a flexbox layout. 3. `flex-direction: column` set the direction of flex items' order from top to down. 4. `flex-grow: 1` the flexbox will apply remaining available space of container to last child element. -- The parent must have a viewport height. `flex-grow: 1` could be applied to the first or second element, which will have all available space. +- 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. #### Browser support -⚠️ Needs prefixes for full support. - - https://caniuse.com/#feat=flexbox diff --git a/snippets/lobotomizedOwlSelector.md b/snippets/lobotomizedOwlSelector.md index 4e557ae97..dde6b4e8c 100644 --- a/snippets/lobotomizedOwlSelector.md +++ b/snippets/lobotomizedOwlSelector.md @@ -1,6 +1,6 @@ --- title: Lobotomized Owl Selector -tags: layout, beginner +tags: layout,beginner --- Sets an automatically inherited margin for all elements that follow other elements in the document. @@ -24,8 +24,8 @@ Sets an automatically inherited margin for all elements that follow other elemen #### Explanation -- [View this link for a detailed explanation.](https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/) - In this example, all elements in the flow of the document that follow other elements will receive `margin-top: 1.5em`. - This example assumes that the paragraphs' `font-size` is 1em and its `line-height` is 1.5. +_Note: You can read [this article](https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/_) for a more detailed explanation._ #### Browser support diff --git a/snippets/masonry-layout.md b/snippets/masonry-layout.md index cd7fa9c8c..3e29a1230 100644 --- a/snippets/masonry-layout.md +++ b/snippets/masonry-layout.md @@ -3,7 +3,7 @@ title: Masonry Layout tags: layout,advanced --- -Creates a vertical Masonry layout using pure HTML and CSS. +Creates a vertical masonry layout using HTML and CSS. ```html
diff --git a/snippets/mouse-cursor-gradient-tracking.md b/snippets/mouse-cursor-gradient-tracking.md index 02fd70927..6191c7e78 100644 --- a/snippets/mouse-cursor-gradient-tracking.md +++ b/snippets/mouse-cursor-gradient-tracking.md @@ -1,12 +1,14 @@ --- title: Mouse cursor gradient tracking -tags: visual, interactivity,advanced +tags: visual,interactivity,advanced --- A hover effect where the gradient follows the mouse cursor. ```html - + ``` ```css @@ -63,6 +65,4 @@ btn.onmousemove = function(e) { #### Browser support -⚠️ Requires JavaScript. - - https://caniuse.com/#feat=css-variables diff --git a/snippets/navigation-list-item-hover-and-focus-effect.md b/snippets/navigation-list-item-hover-and-focus-effect.md index bf75cc6af..cc9bedf84 100644 --- a/snippets/navigation-list-item-hover-and-focus-effect.md +++ b/snippets/navigation-list-item-hover-and-focus-effect.md @@ -49,7 +49,8 @@ li a::before { transition: transform 0.5s ease-in-out; } -li a:hover::before, li a:focus::before { +li a:hover::before, +li a:focus::before { transform: scale(1); } ``` diff --git a/snippets/not-selector.md b/snippets/not-selector.md index 1c9e53cf5..156b2fb3e 100644 --- a/snippets/not-selector.md +++ b/snippets/not-selector.md @@ -1,6 +1,6 @@ --- title: :not selector -tags: visual +tags: visual,beginner --- The `:not` pseudo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled. diff --git a/snippets/offscreen.md b/snippets/offscreen.md index dfbc34b7a..b82804c67 100644 --- a/snippets/offscreen.md +++ b/snippets/offscreen.md @@ -1,9 +1,10 @@ --- title: Offscreen -tags: layout, visual +tags: layout,visual,intermediate --- -A bulletproof way to completely hide an element visually and positionally in the DOM while still allowing it to be accessed by JavaScript and readable by screen readers. This method is very useful for accessibility ([ADA](https://adata.org/learn-about-ada)) development when more context is needed for visually-impaired users. As an alternative to `display: none` which is not readable by screen readers or `visibility: hidden` which takes up physical space in the DOM. +Completely hides an element visually and positionally in the DOM while still allowing it to be accessible. +Provides an alternative to `display: none` (not readable by screen readers) and `visibility: hidden` (takes up physical space in the DOM). ```html @@ -36,6 +37,4 @@ A bulletproof way to completely hide an element visually and positionally in the #### Browser support -(Although `clip` technically has been depreciated, the newer `clip-path` currently has very limited browser support.) - - https://caniuse.com/#search=clip diff --git a/snippets/overflow-scroll-gradient.md b/snippets/overflow-scroll-gradient.md index ec4e216d6..c7e3b0c99 100644 --- a/snippets/overflow-scroll-gradient.md +++ b/snippets/overflow-scroll-gradient.md @@ -1,13 +1,13 @@ --- title: Overflow scroll gradient -tags: visual +tags: visual,intermediate --- Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled. ```html
-
+
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Iure id exercitationem nulla qui repellat laborum vitae,
molestias tempora velit natus. Quas, assumenda nisi.
@@ -24,19 +24,18 @@ Adds a fading gradient to an overflowing element to better indicate there is mor .overflow-scroll-gradient { position: relative; } + .overflow-scroll-gradient::after { content: ''; position: absolute; bottom: 0; width: 250px; height: 25px; - background: linear-gradient( - rgba(255, 255, 255, 0.001), - white - ); /* transparent keyword is broken in Safari */ + background: linear-gradient(transparent, white); pointer-events: none; } -.overflow-scroll-gradient__scroller { + +.overflow-scroll-gradient-scroller { overflow-y: scroll; background: white; width: 240px; diff --git a/snippets/popout-menu.md b/snippets/popout-menu.md index d8f53ea36..18d749bde 100644 --- a/snippets/popout-menu.md +++ b/snippets/popout-menu.md @@ -1,6 +1,6 @@ --- title: Popout menu -tags: interactivity +tags: interactivity,intermediate --- Reveals an interactive popout menu on hover and focus. @@ -16,6 +16,7 @@ Reveals an interactive popout menu on hover and focus. width: 100px; height: 100px; } + .popout-menu { position: absolute; visibility: hidden; @@ -24,6 +25,7 @@ Reveals an interactive popout menu on hover and focus. color: white; padding: 15px; } + .reference:hover > .popout-menu, .reference:focus > .popout-menu, .reference:focus-within > .popout-menu { diff --git a/snippets/pretty-text-underline.md b/snippets/pretty-text-underline.md index 3447a4dd5..4269ea8a1 100644 --- a/snippets/pretty-text-underline.md +++ b/snippets/pretty-text-underline.md @@ -1,9 +1,9 @@ --- title: Pretty text underline -tags: visual +tags: visual,intermediate --- -A nicer alternative to `text-decoration: underline` or `` where descenders do not clip the underline. +A nicer alternative to `text-decoration: underline` where descenders do not clip the underline. Natively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline. ```html @@ -19,10 +19,12 @@ Natively implemented as `text-decoration-skip-ink: auto` but it has less control background-repeat: no-repeat; background-size: 100% 1px; } + .pretty-text-underline::-moz-selection { background-color: rgba(0, 150, 255, 0.3); text-shadow: none; } + .pretty-text-underline::selection { background-color: rgba(0, 150, 255, 0.3); text-shadow: none; diff --git a/snippets/reset-all-styles.md b/snippets/reset-all-styles.md index e6f742995..1dccf1f5e 100644 --- a/snippets/reset-all-styles.md +++ b/snippets/reset-all-styles.md @@ -1,6 +1,6 @@ --- title: Reset all styles -tags: visual +tags: visual,beginner --- Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties. diff --git a/snippets/shape-separator.md b/snippets/shape-separator.md index 0e9afb98f..66722887a 100644 --- a/snippets/shape-separator.md +++ b/snippets/shape-separator.md @@ -1,6 +1,6 @@ --- title: Shape separator -tags: visual +tags: visual,intermediate --- Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation. @@ -15,6 +15,7 @@ Uses an SVG shape to separate two different blocks to create more a interesting height: 48px; background: #333; } + .shape-separator::after { content: ''; 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"); diff --git a/snippets/sibling-fade.md b/snippets/sibling-fade.md index 01d5f69ab..e07a14a1d 100644 --- a/snippets/sibling-fade.md +++ b/snippets/sibling-fade.md @@ -1,6 +1,6 @@ --- title: Sibling fade -tags: interactivity +tags: interactivity,intermediate --- Fades out the siblings of a hovered item. diff --git a/snippets/system-font-stack.md b/snippets/system-font-stack.md index 4bd52ae37..4acd284a3 100644 --- a/snippets/system-font-stack.md +++ b/snippets/system-font-stack.md @@ -1,6 +1,6 @@ --- title: System font stack -tags: visual +tags: visual,beginner --- Uses the native font of the operating system to get close to a native app feel. @@ -18,7 +18,7 @@ Uses the native font of the operating system to get close to a native app feel. #### Explanation -- The 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). +The 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). 1. `-apple-system` is San Francisco, used on iOS and macOS (not Chrome however) 2. `BlinkMacSystemFont` is San Francisco, used on macOS Chrome diff --git a/snippets/toggle-switch.md b/snippets/toggle-switch.md index d225f87aa..16fff2b3d 100644 --- a/snippets/toggle-switch.md +++ b/snippets/toggle-switch.md @@ -1,6 +1,6 @@ --- title: Toggle switch -tags: visual, interactivity +tags: visual,interactivity,beginner --- Creates a toggle switch with CSS only. @@ -48,7 +48,7 @@ input[type='checkbox']:checked + .switch { #### Explanation -- This effect is styling only the `