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);
}
}
.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;
}

View File

@ -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;
}

View File

@ -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

View File

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

View File

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

View File

@ -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
<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;
width: 50%;
}
.constant-width-to-height-ratio::before {
content: '';
padding-top: 100%;
float: left;
}
.constant-width-to-height-ratio::after {
content: '';
display: block;

View File

@ -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

View File

@ -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.

View File

@ -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
<span class="snippet__support-note">⚠️ Requires prefixes for full support and is not actually
in any specification.</span>
<span class="snippet__support-note">⚠️ Requires prefixes for full support and is not actually in any specification.</span>
- https://caniuse.com/#feat=css-selection

View File

@ -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
<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

View File

@ -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`).

View File

@ -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
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
- https://caniuse.com/#feat=css-animation
- https://caniuse.com/#feat=transforms2d

View File

@ -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
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
- https://caniuse.com/#feat=css-filters

View File

@ -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
<div class="easing-variables">Hover</div>

View File

@ -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.

View File

@ -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
<span class="snippet__support-note">⚠️ Needs prefixes for full support.</span>
- https://caniuse.com/#feat=flexbox

View File

@ -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
<span class="snippet__support-note">⚠️ Needs prefixes for full support.</span>
- https://caniuse.com/#feat=flexbox

View File

@ -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 {
}
```
<!-- Leave this blank, the build script will generate the demo for you. -->
#### 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 {
<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

View File

@ -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
<div class="container">
@ -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

View File

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

View File

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

View File

@ -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
<div class="grid-centering"><div class="child">Centered content.</div></div>
<div class="grid-centering">
<div class="child">Centered content.</div>
</div>
```
```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.

View File

@ -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
<div class="hairline-border">text</div>
@ -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
<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
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.
---
<br>
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
<div class="snippet__requires-javascript">Requires JavaScript</div>
<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>
<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>
- https://caniuse.com/#feat=css-variables
- https://caniuse.com/#feat=css-transitions

View File

@ -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 {

View File

@ -1,12 +1,10 @@
---
title: Hover underline animation
tags: animation
tags: animation,advanced
---
Creates an animated underline effect when the text is hovered over.
<small>**Credit:** https://flatuicolors.com/</small>
```html
<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;
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;

View File

@ -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
<span class="snippet__support-note">⚠️ Needs prefixes for full support.</span>
- https://caniuse.com/#feat=flexbox

View File

@ -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

View File

@ -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
<div class="masonry-container">

View File

@ -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
<button class="mouse-cursor-gradient-tracking"><span>Hover me</span></button>
<button class="mouse-cursor-gradient-tracking">
<span>Hover me</span>
</button>
```
```css
@ -63,6 +65,4 @@ btn.onmousemove = function(e) {
#### Browser support
<span class="snippet__support-note">⚠️ Requires JavaScript.</span>
- https://caniuse.com/#feat=css-variables

View File

@ -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);
}
```

View File

@ -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.

View File

@ -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
<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
(Although `clip` technically has been depreciated, the newer `clip-path` currently has very limited browser support.)
- https://caniuse.com/#search=clip

View File

@ -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
<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 />
Iure id exercitationem nulla qui repellat laborum vitae, <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 {
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;

View File

@ -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 {

View File

@ -1,9 +1,9 @@
---
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.
```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;

View File

@ -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.

View File

@ -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");

View File

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

View File

@ -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

View File

@ -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 `<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`.
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
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
- 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
<span class="snippet__support-note">⚠️ Requires prefix for full support.</span>
- https://caniuse.com/#feat=transforms2d

View File

@ -1,6 +1,6 @@
---
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.
@ -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.
- `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
<span class="snippet__support-note">⚠️ Requires prefix for full support.</span>
- https://caniuse.com/#feat=transforms2d

View File

@ -1,6 +1,6 @@
---
title: Triangle
tags: visual
tags: visual,beginner
---
Creates a triangle shape with pure CSS.
@ -21,7 +21,6 @@ Creates a triangle shape with pure CSS.
#### 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.
- Experiment with the `px` values to change the proportion of the triangle.

View File

@ -1,6 +1,6 @@
---
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.

View File

@ -1,6 +1,6 @@
---
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 `…`.

View File

@ -1,6 +1,6 @@
---
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.
@ -24,7 +24,7 @@ li:nth-child(odd) {
#### 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.
- 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