Update tags, expertise and descriptions across

Fix anything that was a bit out of place
This commit is contained in:
Angelos Chalaris
2020-03-05 22:52:51 +02:00
parent e536c78974
commit 7e69307433
47 changed files with 114 additions and 121 deletions

View File

@ -20,10 +20,12 @@ Creates a bouncing loader animation.
transform: translate3d(0, -1rem, 0); transform: translate3d(0, -1rem, 0);
} }
} }
.bouncing-loader { .bouncing-loader {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.bouncing-loader > div { .bouncing-loader > div {
width: 1rem; width: 1rem;
height: 1rem; height: 1rem;
@ -32,9 +34,11 @@ Creates a bouncing loader animation.
border-radius: 50%; border-radius: 50%;
animation: bouncing-loader 0.6s infinite alternate; animation: bouncing-loader 0.6s infinite alternate;
} }
.bouncing-loader > div:nth-child(2) { .bouncing-loader > div:nth-child(2) {
animation-delay: 0.2s; animation-delay: 0.2s;
} }
.bouncing-loader > div:nth-child(3) { .bouncing-loader > div:nth-child(3) {
animation-delay: 0.4s; animation-delay: 0.4s;
} }

View File

@ -1,6 +1,6 @@
--- ---
title: Box-sizing reset 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`. 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 { html {
box-sizing: border-box; box-sizing: border-box;
} }
*, *,
*::before, *::before,
*::after { *::after {
box-sizing: inherit; box-sizing: inherit;
} }
.box { .box {
display: inline-block; display: inline-block;
width: 150px; width: 150px;
@ -28,6 +30,7 @@ html {
color: white; color: white;
border: 10px solid red; border: 10px solid red;
} }
.content-box { .content-box {
box-sizing: content-box; box-sizing: content-box;
} }

View File

@ -1,6 +1,6 @@
--- ---
title: Button border animation title: Button border animation
tags: animation tags: animation,intermediate
--- ---
Creates a border animation on hover. Creates a border animation on hover.
@ -18,6 +18,7 @@ Creates a border animation on hover.
padding: 12px 40px 10px; padding: 12px 40px 10px;
position: relative; position: relative;
} }
.button:before, .button:before,
.button:after { .button:after {
border: 0 solid transparent; border: 0 solid transparent;
@ -27,19 +28,23 @@ Creates a border animation on hover.
position: absolute; position: absolute;
width: 24px; width: 24px;
} }
.button:before { .button:before {
border-top: 2px solid #c47135; border-top: 2px solid #c47135;
left: 0px; left: 0px;
top: -5px; top: -5px;
} }
.button:after { .button:after {
border-bottom: 2px solid #c47135; border-bottom: 2px solid #c47135;
bottom: -5px; bottom: -5px;
right: 0px; right: 0px;
} }
.button:hover { .button:hover {
background-color: #c47135; background-color: #c47135;
} }
.button:hover:before, .button:hover:before,
.button:hover:after { .button:hover:after {
height: 100%; height: 100%;
@ -49,6 +54,6 @@ Creates a border animation on hover.
#### Explanation #### 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 #### Browser support

View File

@ -1,6 +1,6 @@
--- ---
title: Circle title: Circle
tags: visual tags: visual,beginner
--- ---
Creates a circle shape with pure CSS. Creates a circle shape with pure CSS.

View File

@ -1,6 +1,6 @@
--- ---
title: Clearfix title: Clearfix
tags: layout tags: layout,beginner
--- ---
Ensures that an element self-clears its children. Ensures that an element self-clears its children.

View File

@ -3,8 +3,7 @@ title: Constant width to height ratio
tags: layout tags: layout
--- ---
Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion 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).
(i.e., its width to height ratio remains constant).
```html ```html
<div class="constant-width-to-height-ratio"></div> <div class="constant-width-to-height-ratio"></div>
@ -15,11 +14,13 @@ Given an element of variable width, it will ensure its height remains proportion
background: #333; background: #333;
width: 50%; width: 50%;
} }
.constant-width-to-height-ratio::before { .constant-width-to-height-ratio::before {
content: ''; content: '';
padding-top: 100%; padding-top: 100%;
float: left; float: left;
} }
.constant-width-to-height-ratio::after { .constant-width-to-height-ratio::after {
content: ''; content: '';
display: block; display: block;

View File

@ -1,6 +1,6 @@
--- ---
title: Counter 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. 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 #### 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. 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` Used in element that will be countable. Once `counter-reset` initialized, a counter's value can be increased or decreased. 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 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). 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 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). 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. 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 #### Browser support

View File

@ -1,6 +1,6 @@
--- ---
title: Custom scrollbar title: Custom scrollbar
tags: visual tags: visual,advanced
--- ---
Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms. Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms.

View File

@ -1,6 +1,6 @@
--- ---
title: Custom text selection title: Custom text selection
tags: visual tags: visual,beginner
--- ---
Changes the styling of text selection. Changes the styling of text selection.
@ -14,6 +14,7 @@ Changes the styling of text selection.
background: aquamarine; background: aquamarine;
color: black; color: black;
} }
.custom-text-selection::selection { .custom-text-selection::selection {
background: deeppink; background: deeppink;
color: white; color: white;
@ -26,7 +27,6 @@ Changes the styling of text selection.
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Requires prefixes for full support and is not actually <span class="snippet__support-note">⚠️ Requires prefixes for full support and is not actually in any specification.</span>
in any specification.</span>
- https://caniuse.com/#feat=css-selection - https://caniuse.com/#feat=css-selection

View File

@ -1,6 +1,6 @@
--- ---
title: Disable selection title: Disable selection
tags: interactivity tags: interactivity,beginner
--- ---
Makes the content unselectable. Makes the content unselectable.
@ -20,10 +20,8 @@ Makes the content unselectable.
- `user-select: none` specifies that the text cannot be selected. - `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 #### Browser support
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
<br>
<span class="snippet__support-note">⚠️ This is not a secure method to prevent users from copying content.</span>
- https://caniuse.com/#feat=user-select-none - https://caniuse.com/#feat=user-select-none

View File

@ -1,6 +1,6 @@
--- ---
title: Display table centering 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`). Vertically and horizontally centers a child element within its parent element using `display: table` (as an alternative to `flexbox`).

View File

@ -1,6 +1,6 @@
--- ---
title: Donut spinner title: Donut spinner
tags: animation tags: animation,intermediate
--- ---
Creates a donut spinner that can be used to indicate the loading of content. 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); transform: rotate(360deg);
} }
} }
.donut { .donut {
display: inline-block; display: inline-block;
border: 4px solid rgba(0, 0, 0, 0.1); 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 #### Browser support
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
- https://caniuse.com/#feat=css-animation - https://caniuse.com/#feat=css-animation
- https://caniuse.com/#feat=transforms2d - https://caniuse.com/#feat=transforms2d

View File

@ -1,6 +1,6 @@
--- ---
title: Dynamic shadow title: Dynamic shadow
tags: visual tags: visual,intermediate
--- ---
Creates a shadow similar to `box-shadow` but based on the colors of the element itself. 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); background: linear-gradient(75deg, #6d78ff, #00ffb8);
z-index: 1; z-index: 1;
} }
.dynamic-shadow::after { .dynamic-shadow::after {
content: ''; content: '';
width: 100%; width: 100%;
@ -45,6 +46,4 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
- https://caniuse.com/#feat=css-filters - https://caniuse.com/#feat=css-filters

View File

@ -1,10 +1,9 @@
--- ---
title: Easing variables title: Easing variables
tags: animation tags: animation,beginner
--- ---
Variables that can be reused for `transition-timing-function` properties, more 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`.
powerful than the built-in `ease`, `ease-in`, `ease-out` and `ease-in-out`.
```html ```html
<div class="easing-variables">Hover</div> <div class="easing-variables">Hover</div>

View File

@ -1,6 +1,6 @@
--- ---
title: Etched text title: Etched text
tags: visual tags: visual,intermediate
--- ---
Creates an effect where text appears to be "etched" or engraved into the background. Creates an effect where text appears to be "etched" or engraved into the background.

View File

@ -1,6 +1,6 @@
--- ---
title: Evenly distributed children title: Evenly distributed children
tags: layout tags: layout,intermediate
--- ---
Evenly distributes child elements within a parent element. 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. 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. 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 #### Browser support
<span class="snippet__support-note">⚠️ Needs prefixes for full support.</span>
- https://caniuse.com/#feat=flexbox - https://caniuse.com/#feat=flexbox

View File

@ -1,6 +1,6 @@
--- ---
title: Flexbox centering title: Flexbox centering
tags: layout tags: layout,beginner
--- ---
Horizontally and vertically centers a child element within a parent element using `flexbox`. 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 #### Explanation
1. `display: flex` enables flexbox. 1. `display: flex` creates a flexbox layout.
2. `justify-content: center` centers the child horizontally. 2. `justify-content: center` centers the child horizontally.
3. `align-items: center` centers the child vertically. 3. `align-items: center` centers the child vertically.
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Needs prefixes for full support.</span>
- https://caniuse.com/#feat=flexbox - https://caniuse.com/#feat=flexbox

View File

@ -1,6 +1,6 @@
--- ---
title: Focus Within title: Focus Within
tags: visual, interactivity tags: visual,interactivity,intermediate
--- ---
Changes the appearance of a form if any of its children are focused. Changes the appearance of a form if any of its children are focused.
@ -27,8 +27,6 @@ form:focus-within {
} }
``` ```
<!-- Leave this blank, the build script will generate the demo for you. -->
#### Explanation #### 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. - 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 {
<span class="snippet__support-note">⚠️ Not supported in IE11 or the current version of Edge.</span> <span class="snippet__support-note">⚠️ Not supported in IE11 or the current version of Edge.</span>
<!-- Whenever possible, link a `caniuse` feature which allows the browser support percentage to be displayed.
If no link is provided, it defaults to 99+%. -->
- https://caniuse.com/#feat=css-focus-within - https://caniuse.com/#feat=css-focus-within

View File

@ -1,9 +1,9 @@
--- ---
title: Fullscreen 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 ```html
<div class="container"> <div class="container">
@ -49,7 +49,7 @@ The :fullscreen CSS pseudo-class represents an element that's displayed when the
#### Explanation #### 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 #### Browser support

View File

@ -1,6 +1,6 @@
--- ---
title: Ghost trick title: Ghost trick
tags: layout tags: layout,intermediate
--- ---
Vertically centers an element in another. Vertically centers an element in another.

View File

@ -1,6 +1,6 @@
--- ---
title: Gradient text title: Gradient text
tags: visual tags: visual,intermediate
--- ---
Gives text a gradient color. Gives text a gradient color.

View File

@ -1,12 +1,14 @@
--- ---
title: Grid centering title: Grid centering
tags: layout tags: layout,beginner
--- ---
Horizontally and vertically centers a child element within a parent element using `grid`. Horizontally and vertically centers a child element within a parent element using `grid`.
```html ```html
<div class="grid-centering"><div class="child">Centered content.</div></div> <div class="grid-centering">
<div class="child">Centered content.</div>
</div>
``` ```
```css ```css
@ -20,7 +22,7 @@ Horizontally and vertically centers a child element within a parent element usin
#### Explanation #### Explanation
1. `display: grid` enables grid. 1. `display: grid` creates a grid layout
2. `justify-content: center` centers the child horizontally. 2. `justify-content: center` centers the child horizontally.
3. `align-items: center` centers the child vertically. 3. `align-items: center` centers the child vertically.

View File

@ -1,10 +1,9 @@
--- ---
title: Hairline border title: Hairline border
tags: visual tags: visual,advanced
--- ---
Gives an element a border equal to 1 native device pixel in width, which can look Gives an element a border equal to 1 native device pixel in width, which can look very sharp and crisp.
very sharp and crisp.
```html ```html
<div class="hairline-border">text</div> <div class="hairline-border">text</div>
@ -36,7 +35,7 @@ very sharp and crisp.
#### Explanation #### 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`. 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 #### Browser Support
@ -46,6 +45,6 @@ very sharp and crisp.
- https://caniuse.com/#feat=css-boxshadow - https://caniuse.com/#feat=css-boxshadow
- https://caniuse.com/#feat=css-media-resolution - https://caniuse.com/#feat=css-media-resolution
<hr> <br>
\*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.

View File

@ -1,6 +1,6 @@
--- ---
title: Height transition title: Height transition
tags: animation tags: animation,intermediate
--- ---
Transitions an element's height from `0` to `auto` when its height is unknown. 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. 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. 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.
--- <br>
1. `el.scrollHeight` is the height of the element including overflow, which will change dynamically based on the content of the element. 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. 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 #### Browser Support
<div class="snippet__requires-javascript">Requires JavaScript</div> <div class="snippet__requires-javascript">Requires JavaScript</div>
<span class="snippet__support-note"> <span class="snippet__support-note">⚠️ 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.</span>
⚠️ 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.
</span>
- https://caniuse.com/#feat=css-variables - https://caniuse.com/#feat=css-variables
- https://caniuse.com/#feat=css-transitions - https://caniuse.com/#feat=css-transitions

View File

@ -1,6 +1,6 @@
--- ---
title: Hover shadow box animation title: Hover shadow box animation
tags: animation tags: animation,intermediate
--- ---
Creates a shadow box around the text when it is hovered. 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-duration: 0.3s;
transition-property: box-shadow, transform; transition-property: box-shadow, transform;
} }
.hover-shadow-box-animation:hover, .hover-shadow-box-animation:hover,
.hover-shadow-box-animation:focus, .hover-shadow-box-animation:focus,
.hover-shadow-box-animation:active { .hover-shadow-box-animation:active {

View File

@ -1,12 +1,10 @@
--- ---
title: Hover underline animation title: Hover underline animation
tags: animation tags: animation,advanced
--- ---
Creates an animated underline effect when the text is hovered over. Creates an animated underline effect when the text is hovered over.
<small>**Credit:** https://flatuicolors.com/</small>
```html ```html
<p class="hover-underline-animation">Hover this text to see the effect!</p> <p class="hover-underline-animation">Hover this text to see the effect!</p>
``` ```
@ -17,6 +15,7 @@ Creates an animated underline effect when the text is hovered over.
position: relative; position: relative;
color: #0087ca; color: #0087ca;
} }
.hover-underline-animation::after { .hover-underline-animation::after {
content: ''; content: '';
position: absolute; position: absolute;
@ -29,6 +28,7 @@ Creates an animated underline effect when the text is hovered over.
transform-origin: bottom right; transform-origin: bottom right;
transition: transform 0.25s ease-out; transition: transform 0.25s ease-out;
} }
.hover-underline-animation:hover::after { .hover-underline-animation:hover::after {
transform: scaleX(1); transform: scaleX(1);
transform-origin: bottom left; transform-origin: bottom left;

View File

@ -1,6 +1,6 @@
--- ---
title: Last item with remaining available height 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. 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 #### Explanation
1. `height: 100%` set the height of container as viewport height. 1. `height: 100%` sets the height of container as viewport height.
2. `display: flex` enables flexbox. 2. `display: flex` creates a flexbox layout.
3. `flex-direction: column` set the direction of flex items' order from top to down. 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. 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 #### Browser support
<span class="snippet__support-note">⚠️ Needs prefixes for full support.</span>
- https://caniuse.com/#feat=flexbox - https://caniuse.com/#feat=flexbox

View File

@ -1,6 +1,6 @@
--- ---
title: Lobotomized Owl Selector 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. 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 #### 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`. - 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. - 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 #### Browser support

View File

@ -3,7 +3,7 @@ title: Masonry Layout
tags: layout,advanced tags: layout,advanced
--- ---
Creates a vertical Masonry layout using pure HTML and CSS. Creates a vertical masonry layout using HTML and CSS.
```html ```html
<div class="masonry-container"> <div class="masonry-container">

View File

@ -1,12 +1,14 @@
--- ---
title: Mouse cursor gradient tracking title: Mouse cursor gradient tracking
tags: visual, interactivity,advanced tags: visual,interactivity,advanced
--- ---
A hover effect where the gradient follows the mouse cursor. A hover effect where the gradient follows the mouse cursor.
```html ```html
<button class="mouse-cursor-gradient-tracking"><span>Hover me</span></button> <button class="mouse-cursor-gradient-tracking">
<span>Hover me</span>
</button>
``` ```
```css ```css
@ -63,6 +65,4 @@ btn.onmousemove = function(e) {
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Requires JavaScript.</span>
- https://caniuse.com/#feat=css-variables - https://caniuse.com/#feat=css-variables

View File

@ -49,7 +49,8 @@ li a::before {
transition: transform 0.5s ease-in-out; 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); transform: scale(1);
} }
``` ```

View File

@ -1,6 +1,6 @@
--- ---
title: :not selector 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. The `:not` pseudo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.

View File

@ -1,9 +1,10 @@
--- ---
title: Offscreen 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 ```html
<a class="button" href="https://google.com"> <a class="button" href="https://google.com">
@ -36,6 +37,4 @@ A bulletproof way to completely hide an element visually and positionally in the
#### Browser support #### Browser support
(Although `clip` technically has been depreciated, the newer `clip-path` currently has very limited browser support.)
- https://caniuse.com/#search=clip - https://caniuse.com/#search=clip

View File

@ -1,13 +1,13 @@
--- ---
title: Overflow scroll gradient 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. Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled.
```html ```html
<div class="overflow-scroll-gradient"> <div class="overflow-scroll-gradient">
<div class="overflow-scroll-gradient__scroller"> <div class="overflow-scroll-gradient-scroller">
Lorem ipsum dolor sit amet consectetur adipisicing elit. <br /> Lorem ipsum dolor sit amet consectetur adipisicing elit. <br />
Iure id exercitationem nulla qui repellat laborum vitae, <br /> Iure id exercitationem nulla qui repellat laborum vitae, <br />
molestias tempora velit natus. Quas, assumenda nisi. <br /> molestias tempora velit natus. Quas, assumenda nisi. <br />
@ -24,19 +24,18 @@ Adds a fading gradient to an overflowing element to better indicate there is mor
.overflow-scroll-gradient { .overflow-scroll-gradient {
position: relative; position: relative;
} }
.overflow-scroll-gradient::after { .overflow-scroll-gradient::after {
content: ''; content: '';
position: absolute; position: absolute;
bottom: 0; bottom: 0;
width: 250px; width: 250px;
height: 25px; height: 25px;
background: linear-gradient( background: linear-gradient(transparent, white);
rgba(255, 255, 255, 0.001),
white
); /* transparent keyword is broken in Safari */
pointer-events: none; pointer-events: none;
} }
.overflow-scroll-gradient__scroller {
.overflow-scroll-gradient-scroller {
overflow-y: scroll; overflow-y: scroll;
background: white; background: white;
width: 240px; width: 240px;

View File

@ -1,6 +1,6 @@
--- ---
title: Popout menu title: Popout menu
tags: interactivity tags: interactivity,intermediate
--- ---
Reveals an interactive popout menu on hover and focus. Reveals an interactive popout menu on hover and focus.
@ -16,6 +16,7 @@ Reveals an interactive popout menu on hover and focus.
width: 100px; width: 100px;
height: 100px; height: 100px;
} }
.popout-menu { .popout-menu {
position: absolute; position: absolute;
visibility: hidden; visibility: hidden;
@ -24,6 +25,7 @@ Reveals an interactive popout menu on hover and focus.
color: white; color: white;
padding: 15px; padding: 15px;
} }
.reference:hover > .popout-menu, .reference:hover > .popout-menu,
.reference:focus > .popout-menu, .reference:focus > .popout-menu,
.reference:focus-within > .popout-menu { .reference:focus-within > .popout-menu {

View File

@ -1,9 +1,9 @@
--- ---
title: Pretty text underline title: Pretty text underline
tags: visual tags: visual,intermediate
--- ---
A nicer alternative to `text-decoration: underline` or `<u></u>` 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. Natively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline.
```html ```html
@ -19,10 +19,12 @@ Natively implemented as `text-decoration-skip-ink: auto` but it has less control
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 1px; background-size: 100% 1px;
} }
.pretty-text-underline::-moz-selection { .pretty-text-underline::-moz-selection {
background-color: rgba(0, 150, 255, 0.3); background-color: rgba(0, 150, 255, 0.3);
text-shadow: none; text-shadow: none;
} }
.pretty-text-underline::selection { .pretty-text-underline::selection {
background-color: rgba(0, 150, 255, 0.3); background-color: rgba(0, 150, 255, 0.3);
text-shadow: none; text-shadow: none;

View File

@ -1,6 +1,6 @@
--- ---
title: Reset all styles 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. Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties.

View File

@ -1,6 +1,6 @@
--- ---
title: Shape separator 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. 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; height: 48px;
background: #333; background: #333;
} }
.shape-separator::after { .shape-separator::after {
content: ''; 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"); 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");

View File

@ -1,6 +1,6 @@
--- ---
title: Sibling fade title: Sibling fade
tags: interactivity tags: interactivity,intermediate
--- ---
Fades out the siblings of a hovered item. Fades out the siblings of a hovered item.

View File

@ -1,6 +1,6 @@
--- ---
title: System font stack 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. 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 #### 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) 1. `-apple-system` is San Francisco, used on iOS and macOS (not Chrome however)
2. `BlinkMacSystemFont` is San Francisco, used on macOS Chrome 2. `BlinkMacSystemFont` is San Francisco, used on macOS Chrome

View File

@ -1,6 +1,6 @@
--- ---
title: Toggle switch title: Toggle switch
tags: visual, interactivity tags: visual,interactivity,beginner
--- ---
Creates a toggle switch with CSS only. Creates a toggle switch with CSS only.
@ -48,7 +48,7 @@ input[type='checkbox']:checked + .switch {
#### Explanation #### Explanation
- This effect is styling only the `<label>` element to look like a toggle switch, and hiding the actual `<input>` checkbox by positioning it offscreen. When clicking the label associated with the `<input>` element, it sets the `<input>` checkbox into the `:checked` state. This effect is styling only the `<label>` element to look like a toggle switch, and hiding the actual `<input>` checkbox by positioning it offscreen. When clicking the label associated with the `<input>` element, it sets the `<input>` checkbox into the `:checked` state.
1. The `for` attribute associates the `<label>` with the appropriate `<input>` checkbox element by its `id`. 1. The `for` attribute associates the `<label>` with the appropriate `<input>` checkbox element by its `id`.
2. `.switch::after` defines a pseudo-element for the `<label>` to create the circular knob. 2. `.switch::after` defines a pseudo-element for the `<label>` to create the circular knob.
@ -60,6 +60,4 @@ input[type='checkbox']:checked + .switch {
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
- https://caniuse.com/#feat=transforms2d - https://caniuse.com/#feat=transforms2d

View File

@ -36,6 +36,4 @@ Vertically and horizontally centers a child element within its parent element us
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Requires prefix for full support.</span>
- https://caniuse.com/#feat=transforms2d - https://caniuse.com/#feat=transforms2d

View File

@ -1,6 +1,6 @@
--- ---
title: Transform - Detransform title: Transform - Detransform
tags: visual, beginner tags: visual,beginner
--- ---
Sets a transform on the parent element and de-transforms the child elements, so they are not affected by the transform. Sets a transform on the parent element and de-transforms the child elements, so they are not affected by the transform.
@ -32,10 +32,8 @@ This allows for some neat effects such as skewed buttons.
- `--transform: 10deg` sets a CSS variable we can later use to prevent duplicate code. - `--transform: 10deg` sets a CSS variable we can later use to prevent duplicate code.
- `calc(-1 * var(--transform))` on the child element negates the transform from the parent. - `calc(-1 * var(--transform))` on the child element negates the transform from the parent.
- Note: the `display` property of the child element may not be `inline`, otherwise the transform will be ignored ([see also](https://drafts.csswg.org/css-transforms-1/#terminology)). _Note: the `display` property of the child element may not be `inline`, otherwise the transform will be ignored - ([see also](https://drafts.csswg.org/css-transforms-1/#terminology))._
#### Browser support #### Browser support
<span class="snippet__support-note">⚠️ Requires prefix for full support.</span>
- https://caniuse.com/#feat=transforms2d - https://caniuse.com/#feat=transforms2d

View File

@ -1,6 +1,6 @@
--- ---
title: Triangle title: Triangle
tags: visual tags: visual,beginner
--- ---
Creates a triangle shape with pure CSS. Creates a triangle shape with pure CSS.
@ -21,7 +21,6 @@ Creates a triangle shape with pure CSS.
#### Explanation #### Explanation
- [View this link for a detailed explanation.](https://stackoverflow.com/q/7073484)
- The color of the border is the color of the triangle. The side the triangle tip points corresponds to the opposite `border-*` property. For example, a color on `border-top` means the arrow points downward. - The color of the border is the color of the triangle. The side the triangle tip points corresponds to the opposite `border-*` property. For example, a color on `border-top` means the arrow points downward.
- Experiment with the `px` values to change the proportion of the triangle. - Experiment with the `px` values to change the proportion of the triangle.

View File

@ -1,6 +1,6 @@
--- ---
title: Truncate text multiline title: Truncate text multiline
tags: layout tags: layout,intermediate
--- ---
If the text is longer than one line, it will be truncated for `n` lines and end with an gradient fade. If the text is longer than one line, it will be truncated for `n` lines and end with an gradient fade.

View File

@ -1,6 +1,6 @@
--- ---
title: Truncate text title: Truncate text
tags: layout tags: layout,beginner
--- ---
If the text is longer than one line, it will be truncated and end with an ellipsis `…`. If the text is longer than one line, it will be truncated and end with an ellipsis `…`.

View File

@ -1,6 +1,6 @@
--- ---
title: Zebra striped list title: Zebra striped list
tags: visual tags: visual,beginner
--- ---
Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row. Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row.
@ -24,7 +24,7 @@ li:nth-child(odd) {
#### Explanation #### Explanation
- Use the `:nth-child(odd)` or `:nth-child(even)` pseudo-class to apply a different background color to elements that match based on their position in a group of siblings. - Use the `:nth-child(odd)` or `:nth-child(even)` pseudo-class to apply a different background color to elements that match based on their position in a group of siblings.
- Note that you can use it to apply different styles to other HTML elements like div, tr, p, ol, etc. - Note that you can use it to apply different styles to other HTML elements like `div`, `tr`, `p`, `ol`, etc.
#### Browser support #### Browser support