diff --git a/.gitignore b/.gitignore
index ae7a50935..6fb886d91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ node_modules/
.cache/
.DS_Store
dist/
+src_o/
+
diff --git a/README.md b/README.md
index 6ef0d137c..dd8e8ffa1 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,15 @@
# 30 Seconds of CSS
-
+
[](https://github.com/30-seconds/30-seconds-of-css/blob/master/LICENSE) [](http://makeapullrequest.com) [](https://insight.io/github.com/30-seconds/30-seconds-of-css/tree/master/?source=0)
A curated collection of useful CSS snippets you can understand in 30 seconds or less.
-Inspired by [30 seconds of code](https://github.com/Chalarangelo/30-seconds-of-code).
+Inspired by [30 seconds of code](https://github.com/30-seconds/30-seconds-of-code).
## View online
-https://30-seconds.github.io/30-seconds-of-css/
+https://css.30secondsofcode.org
## Contributing
@@ -20,3 +20,2475 @@ See CONTRIBUTING.md for the snippet template.
- [30 Seconds of Code](https://30secondsofcode.org/)
- [30 Seconds of Interviews](https://30secondsofinterviews.org/)
- [30 Seconds of React](https://github.com/30-seconds/30-seconds-of-react)
+
+### Animation
+
+
+View contents
+
+* [`Bouncing loader`](#bouncing-loader)
+* [`Button border animation`](#button-border-animation)
+* [`Donut spinner`](#donut-spinner)
+* [`Easing variables`](#easing-variables)
+* [`Height transition`](#height-transition)
+* [`Hover shadow box animation`](#hover-shadow-box-animation)
+* [`Hover underline animation`](#hover-underline-animation)
+
+
+
+### Interactivity
+
+
+View contents
+
+* [`Disable selection`](#disable-selection)
+* [`Popout menu`](#popout-menu)
+* [`Sibling fade`](#sibling-fade)
+
+
+
+### Layout
+
+
+View contents
+
+* [`Box-sizing reset`](#box-sizing-reset)
+* [`Clearfix`](#clearfix)
+* [`Constant width to height ratio`](#constant-width-to-height-ratio)
+* [`Display table centering`](#display-table-centering)
+* [`Evenly distributed children`](#evenly-distributed-children)
+* [`Fit image in container`](#fit-image-in-container)
+* [`Flexbox centering`](#flexbox-centering)
+* [`Ghost trick`](#ghost-trick)
+* [`Grid centering`](#grid-centering)
+* [`Last item with remaining available height`](#last-item-with-remaining-available-height)
+* [`Offscreen`](#offscreen)
+* [`Transform centering`](#transform-centering)
+* [`Truncate text multiline`](#truncate-text-multiline)
+* [`Truncate text`](#truncate-text)
+
+
+
+### Other
+
+
+View contents
+
+* [`Calc()`](#calc)
+* [`Custom variables`](#custom-variables)
+
+
+
+### Visual
+
+
+View contents
+
+* [`Circle`](#circle)
+* [`Counter`](#counter)
+* [`Custom scrollbar`](#custom-scrollbar)
+* [`Custom text selection`](#custom-text-selection)
+* [`Dynamic shadow`](#dynamic-shadow)
+* [`Etched text`](#etched-text)
+* [`Focus Within`](#focus-within)
+* [`Fullscreen`](#fullscreen)
+* [`Gradient text`](#gradient-text)
+* [`Hairline border`](#hairline-border)
+* [`Mouse cursor gradient tracking`](#mouse-cursor-gradient-tracking)
+* [`:not selector`](#not-selector)
+* [`Overflow scroll gradient`](#overflow-scroll-gradient)
+* [`Pretty text underline`](#pretty-text-underline)
+* [`Reset all styles`](#reset-all-styles)
+* [`Shape separator`](#shape-separator)
+* [`System font stack`](#system-font-stack)
+* [`Toggle switch`](#toggle-switch)
+* [`Triangle`](#triangle)
+* [`Zebra striped list`](#zebra-striped-list)
+
+
+
+
+---
+
+## Animation
+
+
+### Bouncing loader
+
+Creates a bouncing loader animation.
+
+```html
+
You can select me.
+` HTML element.
+2. 100% height and width on '.center' allows the element to fill the available space within its parent element.
+3. `display: table-cell` on '.center > span' allows the element to behave like an HTML element.
+4. `text-align: center` on '.center > span' centers the child element horizontally.
+5. `vertical-align: middle` on '.center > span' centers the child element vertically.
+
+The outer parent ('.container' in this case) must have a fixed height and width.
+
+
+#### Browser support
+
+Infinity%
+
+- https://caniuse.com/#search=display%3A%20table
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Evenly distributed children
+
+Evenly distributes child elements within a parent element.
+
+```html
+
+
Item1
+
Item2
+
Item3
+
+```
+
+```css
+.evenly-distributed-children {
+ display: flex;
+ justify-content: space-between;
+}
+```
+
+
+#### Explanation
+
+
+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.
+
+
+#### Browser support
+
+100.0%
+
+⚠️ Needs prefixes for full support.
+
+- https://caniuse.com/#feat=flexbox
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Fit image in container
+
+Changes the fit and position of an image within its container while preserving its aspect ratio. Previously only possible using a background image and the `background-size` property.
+
+```html
+
+
+```
+
+```css
+.image {
+ background: #34495e;
+ border: 1px solid #34495e;
+ width: 200px;
+ height: 200px;
+}
+
+.image-contain {
+ object-fit: contain;
+ object-position: center;
+}
+
+.image-cover {
+ object-fit: cover;
+ object-position: right top;
+}
+```
+
+
+#### Explanation
+
+
+- `object-fit: contain` fits the entire image within the container while preserving its aspect ratio.
+- `object-fit: cover` fills the container with the image while preserving its aspect ratio.
+- `object-position: [x] [y]` positions the image within the container.
+
+
+#### Browser support
+
+99.5%
+
+- https://caniuse.com/#feat=object-fit
+
+ [⬆ Back to top](#contents)
+
+### Flexbox centering
+
+Horizontally and vertically centers a child element within a parent element using `flexbox`.
+
+```html
+
+```
+
+```css
+.flexbox-centering {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100px;
+}
+```
+
+
+#### Explanation
+
+
+1. `display: flex` enables flexbox.
+2. `justify-content: center` centers the child horizontally.
+3. `align-items: center` centers the child vertically.
+
+
+#### Browser support
+
+100.0%
+
+⚠️ Needs prefixes for full support.
+
+- https://caniuse.com/#feat=flexbox
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Ghost trick
+
+Vertically centers an element in another.
+
+```html
+
+
Vertically centered without changing the position property.
+
+```
+
+```css
+.ghosting {
+ height: 300px;
+ background: #0ff;
+}
+
+.ghosting:before {
+ content: '';
+ display: inline-block;
+ height: 100%;
+ vertical-align: middle;
+}
+
+p {
+ display: inline-block;
+ vertical-align: middle;
+}
+```
+
+
+#### Explanation
+
+
+Use the style of a `:before` pseudo-element to vertically align inline elements without changing their `position` property.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=inline-block
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Grid centering
+
+Horizontally and vertically centers a child element within a parent element using `grid`.
+
+```html
+
+```
+
+```css
+.grid-centering {
+ display: grid;
+ justify-content: center;
+ align-items: center;
+ height: 100px;
+}
+```
+
+
+#### Explanation
+
+
+1. `display: grid` enables grid.
+2. `justify-content: center` centers the child horizontally.
+3. `align-items: center` centers the child vertically.
+
+
+#### Browser support
+
+97.3%
+
+- https://caniuse.com/#feat=css-grid
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Last item with remaining available height
+
+Take advantage of available viewport space by giving the last element the remaining available space in current viewport, even when resizing the window.
+
+```html
+
+
Div 1
+
Div 2
+
Div 3
+
+```
+
+```css
+html,
+body {
+ height: 100%;
+ margin: 0;
+}
+
+.container {
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+}
+
+.container > div:last-child {
+ background-color: tomato;
+ flex: 1;
+}
+```
+
+
+#### Explanation
+
+
+1. `height: 100%` set the height of container as viewport height.
+2. `display: flex` enables flexbox.
+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.
+
+
+#### Browser support
+
+100.0%
+
+⚠️ Needs prefixes for full support.
+
+- https://caniuse.com/#feat=flexbox
+
+ [⬆ Back to top](#contents)
+
+### Offscreen
+
+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.
+
+```html
+
+ Learn More about pants
+
+```
+
+```css
+.offscreen {
+ border: 0;
+ clip: rect(0 0 0 0);
+ height: 1px;
+ margin: -1px;
+ overflow: hidden;
+ padding: 0;
+ position: absolute;
+ width: 1px;
+}
+```
+
+
+#### Explanation
+
+
+1. Remove all borders.
+2. Use `clip` to indicate that no part of the element should be shown.
+3. Make the height and width of the element 1px.
+4. Negate the elements height and width using `margin: -1px`.
+5. Hide the element's overflow.
+6. Remove all padding.
+7. Position the element absolutely so that it does not take up space in the DOM.
+
+
+#### Browser support
+
+Infinity%
+
+(Although `clip` technically has been depreciated, the newer `clip-path` currently has very limited browser support.)
+
+- https://caniuse.com/#search=clip
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Transform centering
+
+Vertically and horizontally centers a child element within its parent element using `position: absolute` and `transform: translate()` (as an alternative to `flexbox` or `display: table`). Similar to `flexbox`, this method does not require you to know the height or width of your parent or child so it is ideal for responsive applications.
+
+```html
+
+```
+
+```css
+.parent {
+ border: 1px solid #333;
+ height: 250px;
+ position: relative;
+ width: 250px;
+}
+
+.child {
+ left: 50%;
+ position: absolute;
+ top: 50%;
+ transform: translate(-50%, -50%);
+ text-align: center;
+}
+```
+
+
+#### Explanation
+
+
+1. `position: absolute` on the child element allows it to be positioned based on its containing block.
+2. `left: 50%` and `top: 50%` offsets the child 50% from the left and top edge of its containing block.
+3. `transform: translate(-50%, -50%)` allows the height and width of the child element to be negated so that it is vertically and horizontally centered.
+
+Note: Fixed height and width on parent element is for the demo only.
+
+
+#### Browser support
+
+100.0%
+
+⚠️ Requires prefix for full support.
+
+- https://caniuse.com/#feat=transforms2d
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Truncate text multiline
+
+If the text is longer than one line, it will be truncated for `n` lines and end with an gradient fade.
+
+```html
+
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
+ labore et.
+
+```
+
+```css
+.truncate-text-multiline {
+ overflow: hidden;
+ display: block;
+ height: 109.2px;
+ margin: 0 auto;
+ font-size: 26px;
+ line-height: 1.4;
+ width: 400px;
+ position: relative;
+}
+
+.truncate-text-multiline:after {
+ content: '';
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ width: 150px;
+ height: 36.4px;
+ background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%);
+}
+```
+
+
+#### Explanation
+
+
+1. `overflow: hidden` prevents the text from overflowing its dimensions
+ (for a block, 100% width and auto height).
+2. `width: 400px` ensures the element has a dimension.
+3. `height: 109.2px` calculated value for height, it equals `font-size * line-height * numberOfLines` (in this case `26 * 1.4 * 3 = 109.2`)
+4. `height: 36.4px` calculated value for gradient container, it equals `font-size * line-height` (in this case `26 * 1.4 = 36.4`)
+5. `background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%)` gradient from `transparent` to `#f5f6f9`
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=css-gradients
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Truncate text
+
+If the text is longer than one line, it will be truncated and end with an ellipsis `…`.
+
+```html
+If I exceed one line's width, I will be truncated.
+```
+
+```css
+.truncate-text {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ width: 200px;
+}
+```
+
+
+#### Explanation
+
+
+1. `overflow: hidden` prevents the text from overflowing its dimensions
+ (for a block, 100% width and auto height).
+2. `white-space: nowrap` prevents the text from exceeding one line in height.
+3. `text-overflow: ellipsis` makes it so that if the text exceeds its dimensions, it
+ will end with an ellipsis.
+4. `width: 200px;` ensures the element has a dimension, to know when to get ellipsis
+
+
+#### Browser support
+
+100.0%
+
+⚠️ Only works for single line elements.
+
+- https://caniuse.com/#feat=text-overflow
+
+
+
+
+ [⬆ Back to top](#contents)
+
+---
+
+## Other
+
+
+### Calc()
+
+The function calc() allows to define CSS values with the use of mathematical expressions, the value adopted for the property is the result of a mathematical expression.
+
+
+
+```html
+
+```
+
+```css
+.box-example {
+ height: 280px;
+ background: #222 url('https://image.ibb.co/fUL9nS/wolf.png') no-repeat;
+ background-position: calc(100% - 20px) calc(100% - 20px);
+}
+```
+
+
+#### Explanation
+
+
+1. It allows addition, subtraction, multiplication and division.
+2. Can use different units (pixel and percent together, for example) for each value in your expression.
+3. It is permitted to nest calc() functions.
+4. It can be used in any property that ``, ``, ``, ``, ``, ``, or `` is allowed, like width, height, font-size, top, left, etc.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=calc
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Custom variables
+
+CSS variables that contain specific values to be reused throughout a document.
+
+```html
+CSS is awesome!
+```
+
+```css
+:root {
+ /* Place variables within here to use the variables globally. */
+}
+
+.custom-variables {
+ --some-color: #da7800;
+ --some-keyword: italic;
+ --some-size: 1.25em;
+ --some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray, 0 0 0.2em slategray;
+ color: var(--some-color);
+ font-size: var(--some-size);
+ font-style: var(--some-keyword);
+ text-shadow: var(--some-complex-value);
+}
+```
+
+
+#### Explanation
+
+
+The variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document. Variables can also be scoped to a selector if defined within the block.
+
+Declare a variable with `--variable-name:`.
+
+Reuse variables throughout the document using the `var(--variable-name)` function.
+
+
+#### Browser support
+
+96.5%
+
+- https://caniuse.com/#feat=css-variables
+
+
+
+
+ [⬆ Back to top](#contents)
+
+---
+
+## Visual
+
+
+### Circle
+
+Creates a circle shape with pure CSS.
+
+```html
+
+```
+
+```css
+.circle {
+ border-radius: 50%;
+ width: 2rem;
+ height: 2rem;
+ background: #333;
+}
+```
+
+
+#### Explanation
+
+
+`border-radius: 50%` curves the borders of an element to create a circle.
+
+Since a circle has the same radius at any given point, the `width` and `height` must be the same. Differing
+values will create an ellipse.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=border-radius
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Counter
+
+Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.
+
+```html
+
+ List item
+ List item
+
+ List item
+
+ List item
+ List item
+ List item
+
+
+
+```
+
+```css
+ul {
+ counter-reset: counter;
+}
+
+li::before {
+ counter-increment: counter;
+ content: counters(counter, '.') ' ';
+}
+```
+
+
+#### Explanation
+
+
+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).
+
+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
+
+100.0%
+
+- https://caniuse.com/#feat=css-counters
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Custom scrollbar
+
+Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms.
+
+
+
+```html
+
+```
+
+```css
+.custom-scrollbar {
+ height: 70px;
+ overflow-y: scroll;
+}
+
+/* To style the document scrollbar, remove `.custom-scrollbar` */
+
+.custom-scrollbar::-webkit-scrollbar {
+ width: 8px;
+}
+
+.custom-scrollbar::-webkit-scrollbar-track {
+ box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
+ border-radius: 10px;
+}
+
+.custom-scrollbar::-webkit-scrollbar-thumb {
+ border-radius: 10px;
+ box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
+}
+```
+
+
+#### Explanation
+
+
+1. `::-webkit-scrollbar` targets the whole scrollbar element.
+2. `::-webkit-scrollbar-track` targets only the scrollbar track.
+3. `::-webkit-scrollbar-thumb` targets the scrollbar thumb.
+
+There are many other pseudo-elements that you can use to style scrollbars. For more info, visit the [WebKit Blog](https://webkit.org/blog/363/styling-scrollbars/).
+
+
+#### Browser support
+
+97.7%
+
+⚠️ Scrollbar styling doesn't appear to be on any standards track.
+
+- https://caniuse.com/#feat=css-scrollbar
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Custom text selection
+
+Changes the styling of text selection.
+
+```html
+Select some of this text.
+```
+
+```css
+::selection {
+ background: aquamarine;
+ color: black;
+}
+.custom-text-selection::selection {
+ background: deeppink;
+ color: white;
+}
+```
+
+
+#### Explanation
+
+
+`::selection` defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element.
+
+
+#### Browser support
+
+90.1%
+
+⚠️ Requires prefixes for full support and is not actually
+in any specification.
+
+- https://caniuse.com/#feat=css-selection
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Dynamic shadow
+
+Creates a shadow similar to `box-shadow` but based on the colors of the element itself.
+
+```html
+
+```
+
+```css
+.dynamic-shadow {
+ position: relative;
+ width: 10rem;
+ height: 10rem;
+ background: linear-gradient(75deg, #6d78ff, #00ffb8);
+ z-index: 1;
+}
+.dynamic-shadow::after {
+ content: '';
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ background: inherit;
+ top: 0.5rem;
+ filter: blur(0.4rem);
+ opacity: 0.7;
+ z-index: -1;
+}
+```
+
+
+#### Explanation
+
+
+1. `position: relative` on the element establishes a Cartesian positioning context for psuedo-elements.
+2. `z-index: 1` establishes a new stacking context.
+3. `::after` defines a pseudo-element.
+4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.
+5. `width: 100%` and `height: 100%` sizes the pseudo-element to fill its parent's dimensions, making it equal in size.
+6. `background: inherit` causes the pseudo-element to inherit the linear gradient specified on the element.
+7. `top: 0.5rem` offsets the pseudo-element down slightly from its parent.
+8. `filter: blur(0.4rem)` will blur the pseudo-element to create the appearance of a shadow underneath.
+9. `opacity: 0.7` makes the pseudo-element partially transparent.
+10. `z-index: -1` positions the pseudo-element behind the parent but in front of the background.
+
+
+#### Browser support
+
+98.5%
+
+⚠️ Requires prefixes for full support.
+
+- https://caniuse.com/#feat=css-filters
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Etched text
+
+Creates an effect where text appears to be "etched" or engraved into the background.
+
+```html
+I appear etched into the background.
+```
+
+```css
+.etched-text {
+ text-shadow: 0 2px white;
+ font-size: 1.5rem;
+ font-weight: bold;
+ color: #b8bec5;
+}
+```
+
+
+#### Explanation
+
+
+`text-shadow: 0 2px white` creates a white shadow offset `0px` horizontally and `2px` vertically
+from the origin position.
+
+The background must be darker than the shadow for the effect to work.
+
+The text color should be slightly faded to make it look like it's engraved/carved out
+of the background.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=css-textshadow
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Focus Within
+
+Changes the appearance of a form if any of its children are focused.
+
+```html
+
+
+
+```
+
+```css
+form {
+ border: 3px solid #2d98da;
+ color: #000000;
+ padding: 4px;
+}
+
+form:focus-within {
+ background: #f7b731;
+ color: #000000;
+}
+```
+
+
+#### 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.
+
+
+#### Browser support
+
+85.4%
+
+⚠️ Not supported in IE11 or the current version of Edge.
+
+
+
+- https://caniuse.com/#feat=css-focus-within
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Fullscreen
+
+The :fullscreen CSS pseudo-class represents an element that's displayed when the browser is in fullscreen mode.
+
+```html
+
+
Click the button below to enter the element into fullscreen mode.
+
I change color in fullscreen mode!
+
+
+ Go Full Screen!
+
+
+```
+
+```css
+.container {
+ margin: 40px auto;
+ max-width: 700px;
+}
+
+.element {
+ padding: 20px;
+ height: 300px;
+ width: 100%;
+ background-color: skyblue;
+}
+
+.element p {
+ text-align: center;
+ color: white;
+ font-size: 3em;
+}
+
+.element:-ms-fullscreen p {
+ visibility: visible;
+}
+
+.element:fullscreen {
+ background-color: #e4708a;
+ width: 100vw;
+ height: 100vh;
+}
+```
+
+
+#### Explanation
+
+
+1. `fullscreen` CSS pseudo-class selector is used to select and style an element that is being displayed in fullscreen mode.
+
+
+#### Browser support
+
+99.1%
+
+- https://developer.mozilla.org/en-US/docs/Web/CSS/:fullscreen
+- https://caniuse.com/#feat=fullscreen
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Gradient text
+
+Gives text a gradient color.
+
+```html
+Gradient text
+```
+
+```css
+.gradient-text {
+ background: -webkit-linear-gradient(pink, red);
+ -webkit-text-fill-color: transparent;
+ -webkit-background-clip: text;
+}
+```
+
+
+#### Explanation
+
+
+1. `background: -webkit-linear-gradient(...)` gives the text element a gradient background.
+2. `webkit-text-fill-color: transparent` fills the text with a transparent color.
+3. `webkit-background-clip: text` clips the background with the text, filling the text with
+ the gradient background as the color.
+
+
+#### Browser support
+
+98.7%
+
+⚠️ Uses non-standard properties.
+
+- https://caniuse.com/#feat=text-stroke
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Hairline border
+
+Gives an element a border equal to 1 native device pixel in width, which can look
+very sharp and crisp.
+
+```html
+text
+```
+
+```css
+.hairline-border {
+ box-shadow: 0 0 0 1px;
+}
+
+@media (min-resolution: 2dppx) {
+ .hairline-border {
+ box-shadow: 0 0 0 0.5px;
+ }
+}
+
+@media (min-resolution: 3dppx) {
+ .hairline-border {
+ box-shadow: 0 0 0 0.33333333px;
+ }
+}
+
+@media (min-resolution: 4dppx) {
+ .hairline-border {
+ box-shadow: 0 0 0 0.25px;
+ }
+}
+```
+
+
+#### Explanation
+
+
+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
+
+100.0%
+
+⚠️ Needs alternate syntax and JavaScript user agent checking for full support.
+
+- 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.
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Mouse cursor gradient tracking
+
+A hover effect where the gradient follows the mouse cursor.
+
+**Credit:** [Tobias Reich](https://codepen.io/electerious/pen/MQrRxX)
+
+```html
+Hover me
+```
+
+```css
+.mouse-cursor-gradient-tracking {
+ position: relative;
+ background: #7983ff;
+ padding: 0.5rem 1rem;
+ font-size: 1.2rem;
+ border: none;
+ color: white;
+ cursor: pointer;
+ outline: none;
+ overflow: hidden;
+}
+
+.mouse-cursor-gradient-tracking span {
+ position: relative;
+}
+
+.mouse-cursor-gradient-tracking::before {
+ --size: 0;
+ content: '';
+ position: absolute;
+ left: var(--x);
+ top: var(--y);
+ width: var(--size);
+ height: var(--size);
+ background: radial-gradient(circle closest-side, pink, transparent);
+ transform: translate(-50%, -50%);
+ transition: width 0.2s ease, height 0.2s ease;
+}
+
+.mouse-cursor-gradient-tracking:hover::before {
+ --size: 200px;
+}
+```
+
+```js
+var btn = document.querySelector('.mouse-cursor-gradient-tracking')
+btn.onmousemove = function(e) {
+ var x = e.pageX - btn.offsetLeft - btn.offsetParent.offsetLeft
+ var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop
+ btn.style.setProperty('--x', x + 'px')
+ btn.style.setProperty('--y', y + 'px')
+}
+```
+
+
+#### Explanation
+
+
+1. `--x` and `--y` are used to track the position of the mouse on the button.
+2. `--size` is used to keep modify of the gradient's dimensions.
+3. `background: radial-gradient(circle closest-side, pink, transparent);` creates the gradient at the correct postion.
+
+
+#### Browser support
+
+96.5%
+
+Requires JavaScript
+⚠️ Requires JavaScript.
+
+- https://caniuse.com/#feat=css-variables
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### :not selector
+
+The `:not` psuedo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.
+
+```html
+
+ One
+ Two
+ Three
+ Four
+
+```
+
+```css
+.css-not-selector-shortcut {
+ display: flex;
+}
+
+ul {
+ padding-left: 0;
+}
+
+li {
+ list-style-type: none;
+ margin: 0;
+ padding: 0 0.75rem;
+}
+
+li:not(:last-child) {
+ border-right: 2px solid #d2d5e4;
+}
+```
+
+
+#### Explanation
+
+
+`li:not(:last-child)` specifies that the styles should apply to all `li` elements except
+the `:last-child`.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=css-sel3
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Overflow scroll gradient
+
+Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled.
+
+```html
+
+```
+
+```css
+.overflow-scroll-gradient {
+ position: relative;
+}
+.overflow-scroll-gradient::after {
+ content: '';
+ position: absolute;
+ bottom: 0;
+ width: 240px;
+ height: 25px;
+ background: linear-gradient(
+ rgba(255, 255, 255, 0.001),
+ white
+ ); /* transparent keyword is broken in Safari */
+ pointer-events: none;
+}
+.overflow-scroll-gradient__scroller {
+ overflow-y: scroll;
+ background: white;
+ width: 240px;
+ height: 200px;
+ padding: 15px;
+ line-height: 1.2;
+}
+```
+
+
+#### Explanation
+
+
+1. `position: relative` on the parent establishes a Cartesian positioning context for pseudo-elements.
+2. `::after` defines a pseudo element.
+3. `background-image: linear-gradient(...)` adds a linear gradient that fades from transparent to white
+ (top to bottom).
+4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.
+5. `width: 240px` matches the size of the scrolling element (which is a child of the parent that has
+ the pseudo element).
+6. `height: 25px` is the height of the fading gradient pseudo-element, which should be kept relatively small.
+7. `bottom: 0` positions the pseudo-element at the bottom of the parent.
+8. `pointer-events: none` specifies that the pseudo-element cannot be a target of mouse events, allowing text behind it to still be selectable/interactive.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=css-gradients
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Pretty text underline
+
+A nicer alternative to `text-decoration: underline` or ` ` where descenders do not clip the underline.
+Natively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline.
+
+```html
+Pretty text underline without clipping descending letters.
+```
+
+```css
+.pretty-text-underline {
+ display: inline;
+ text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;
+ background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);
+ background-position: bottom;
+ 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;
+}
+```
+
+
+#### Explanation
+
+
+1. `text-shadow` uses 4 values with offsets that cover a 4x4 px area to ensure the underline
+ has a "thick" shadow that covers the line where descenders clip it. Use a color
+ that matches the background. For a larger font, use a larger `px` size. Additional values
+ can create an even thicker shadow, and subpixel values can also be used.
+2. `background-image: linear-gradient(...)` creates a 90deg gradient using the
+ text color (`currentColor`).
+3. The `background-*` properties size the gradient as 100% of the width of the block and 1px
+ in height at the bottom and disables repetition, which creates a 1px underline beneath
+ the text.
+4. The `::selection` pseudo selector rule ensures the text shadow does not interfere with text
+ selection.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=css-textshadow
+- https://caniuse.com/#feat=css-gradients
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Reset all styles
+
+Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties.
+
+```html
+
+
Title
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui
+ repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui
+ iure, consequatur velit sit?
+
+
+```
+
+```css
+.reset-all-styles {
+ all: initial;
+}
+```
+
+
+#### Explanation
+
+
+The `all` property allows you to reset all styles (inherited or not) to default values.
+
+
+#### Browser support
+
+95.8%
+
+⚠️ MS Edge status is under consideration.
+
+- https://caniuse.com/#feat=css-all
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Shape separator
+
+Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.
+
+```html
+
+```
+
+```css
+.shape-separator {
+ position: relative;
+ 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");
+ position: absolute;
+ width: 100%;
+ height: 12px;
+ bottom: 0;
+}
+```
+
+
+#### Explanation
+
+
+1. `position: relative` on the element establishes a Cartesian positioning context for pseudo elements.
+2. `::after` defines a pseudo element.
+3. `background-image: url(...)` adds the SVG shape (a 24x12 triangle) as the background image of the pseudo element, which repeats by default. It must be the same color as the block that is being separated. For other shapes, we can use [the URL-encoder for SVG](http://yoksel.github.io/url-encoder/).
+4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.
+5. `width: 100%` ensures the element stretches the entire width of its parent.
+6. `height: 12px` is the same height as the shape.
+7. `bottom: 0` positions the pseudo element at the bottom of the parent.
+
+
+#### Browser support
+
+100.0%
+
+- https://caniuse.com/#feat=svg
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### System font stack
+
+Uses the native font of the operating system to get close to a native app feel.
+
+```html
+This text uses the system font.
+```
+
+```css
+.system-font-stack {
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,
+ Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+```
+
+
+#### 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).
+
+1. `-apple-system` is San Francisco, used on iOS and macOS (not Chrome however)
+2. `BlinkMacSystemFont` is San Francisco, used on macOS Chrome
+3. `Segoe UI` is used on Windows 10
+4. `Roboto` is used on Android
+5. `Oxygen-Sans` is used on Linux with KDE
+6. `Ubuntu` is used on Ubuntu (all variants)
+7. `Cantarell` is used on Linux with GNOME Shell
+8. `"Helvetica Neue"` and `Helvetica` is used on macOS 10.10 and below (wrapped in quotes because it has a space)
+9. `Arial` is a font widely supported by all operating systems
+10. `sans-serif` is the fallback sans-serif font if none of the other fonts are supported
+
+
+#### Browser support
+
+Infinity%
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Toggle switch
+
+Creates a toggle switch with CSS only.
+
+```html
+
+```
+
+```css
+.switch {
+ position: relative;
+ display: inline-block;
+ width: 40px;
+ height: 20px;
+ background-color: rgba(0, 0, 0, 0.25);
+ border-radius: 20px;
+ transition: all 0.3s;
+}
+
+.switch::after {
+ content: '';
+ position: absolute;
+ width: 18px;
+ height: 18px;
+ border-radius: 18px;
+ background-color: white;
+ top: 1px;
+ left: 1px;
+ transition: all 0.3s;
+}
+
+input[type='checkbox']:checked + .switch::after {
+ transform: translateX(20px);
+}
+
+input[type='checkbox']:checked + .switch {
+ background-color: #7983ff;
+}
+
+.offscreen {
+ position: absolute;
+ left: -9999px;
+}
+```
+
+
+#### Explanation
+
+
+This effect is styling only the `` element to look like a toggle switch, and hiding the actual ` ` checkbox by positioning it offscreen. When clicking the label associated with the ` ` element, it sets the ` ` checkbox into the `:checked` state.
+
+1. The `for` attribute associates the `` with the appropriate ` ` checkbox element by its `id`.
+2. `.switch::after` defines a pseudo-element for the `` to create the circular knob.
+3. `input[type='checkbox']:checked + .switch::after` targets the ``'s pseudo-element's style when the checkbox is `checked`.
+4. `transform: translateX(20px)` moves the pseudo-element (knob) 20px to the right when the checkbox is `checked`.
+5. `background-color: #7983ff;` sets the background-color of the switch to a different color when the checkbox is `checked`.
+6. `.offscreen` moves the ` ` checkbox element, which does not comprise any part of the actual toggle switch, out of the flow of document and positions it far away from the view, but does not hide it so it is accessible via keyboard and screen readers.
+7. `transition: all 0.3s` specifies all property changes will be transitioned over 0.3 seconds, therefore transitioning the ``'s `background-color` and the pseudo-element's `transform` property when the checkbox is checked.
+
+
+#### Browser support
+
+100.0%
+
+⚠️ Requires prefixes for full support.
+
+- https://caniuse.com/#feat=transforms2d
+
+ [⬆ Back to top](#contents)
+
+### Triangle
+
+Creates a triangle shape with pure CSS.
+
+```html
+
+```
+
+```css
+.triangle {
+ width: 0;
+ height: 0;
+ border-top: 20px solid #333;
+ border-left: 20px solid transparent;
+ border-right: 20px solid transparent;
+}
+```
+
+
+#### 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.
+
+
+#### Browser support
+
+Infinity%
+
+
+
+
+ [⬆ Back to top](#contents)
+
+### Zebra striped list
+
+Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row.
+
+```html
+
+ Item 01
+ Item 02
+ Item 03
+ Item 04
+ Item 05
+
+```
+
+```css
+li:nth-child(odd) {
+ background-color: #ddd;
+}
+```
+
+
+#### Explanation
+
+
+1. 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.
+
+
+#### Browser support
+
+100.0%
+
+https://caniuse.com/#feat=css-sel3
+
+ [⬆ Back to top](#contents)
+
+---
+
+_This README is built using [markdown-builder](https://github.com/30-seconds/markdown-builder)._
+
diff --git a/config.js b/config.js
new file mode 100644
index 000000000..51f6f0f7a
--- /dev/null
+++ b/config.js
@@ -0,0 +1,18 @@
+module.exports = {
+ // Project metadata
+ name: `30 seconds of CSS`,
+ description: `A curated collection of useful CSS snippets you can understand in 30 seconds or less.`,
+ shortName: `30s`,
+ repositoryUrl: `https://github.com/30-seconds/30-seconds-of-css`,
+ siteUrl: `https://css.30secondsofcode.org`,
+ // Path information
+ snippetPath: `snippets`,
+ snippetDataPath: `snippet_data`,
+ assetPath: `assets`,
+ pagePath: `src/docs/pages`,
+ staticPartsPath: `src/static-parts`,
+ // General information
+ language: `css`,
+ secondLanguage: `html`,
+ optionalLanguage: `js`,
+};
diff --git a/docs/blob.04a97260.png b/docs/blob.04a97260.png
deleted file mode 100644
index 554b11981..000000000
Binary files a/docs/blob.04a97260.png and /dev/null differ
diff --git a/docs/favicon-32x32.ce990b8a.png b/docs/favicon-32x32.ce990b8a.png
deleted file mode 100644
index 3ce4960e3..000000000
Binary files a/docs/favicon-32x32.ce990b8a.png and /dev/null differ
diff --git a/docs/index.html b/docs/index.html
deleted file mode 100644
index a458499f2..000000000
--- a/docs/index.html
+++ /dev/null
@@ -1,773 +0,0 @@
- 30 Seconds of CSS all layout visual animation interactivity other Bouncing loader animation Creates a bouncing loader animation.
HTML <div class="bouncing-loader">
- <div></div>
- <div></div>
- <div></div>
-</div>
- CSS @keyframes bouncing-loader {
- to {
- opacity: 0.1;
- transform: translate3d(0, -1rem, 0);
- }
-}
-.bouncing-loader {
- display: flex;
- justify-content: center;
-}
-.bouncing-loader > div {
- width: 1rem;
- height: 1rem;
- margin: 3rem 0.2rem;
- background: #8385aa;
- 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;
-}
- Demo Explanation Note: 1rem is usually 16px.
@keyframes defines an animation that has two states, where the element changes opacity and is translated up on the 2D plane using transform: translate3d(). Using a single axis translation on transform: translate3d() improves the performance of the animation.
.bouncing-loader is the parent container of the bouncing circles and uses display: flex and justify-content: center to position them in the center.
.bouncing-loader > div, targets the three child divs of the parent to be styled. The divs are given a width and height of 1rem, using border-radius: 50% to turn them from squares to circles.
margin: 3rem 0.2rem specifies that each circle has a top/bottom margin of 3rem and left/right margin of 0.2rem so that they do not directly touch each other, giving them some breathing room.
animation is a shorthand property for the various animation properties: animation-name, animation-duration, animation-iteration-count, animation-direction are used.
nth-child(n) targets the element which is the nth child of its parent.
animation-delay is used on the second and third div respectively, so that each element does not start the animation at the same time.
Browser support Box-sizing reset layout Resets the box-model so that widths and heights are not affected by their borders or padding.
HTML <div class="box">border-box</div>
-<div class="box content-box">content-box</div>
- CSS html {
- box-sizing: border-box;
-}
-*,
-*::before,
-*::after {
- box-sizing: inherit;
-}
-.box {
- display: inline-block;
- width: 150px;
- height: 150px;
- padding: 10px;
- background: tomato;
- color: white;
- border: 10px solid red;
-}
-.content-box {
- box-sizing: content-box;
-}
- Demo Explanation box-sizing: border-box makes the addition of padding or borders not affect an element's width or height. box-sizing: inherit makes an element respect its parent's box-sizing rule. Browser support Creates a border animation on hover.
HTML <div class="button-border"><button class="button">Submit</button></div>
- CSS .button {
- background-color: #c47135;
- border: none;
- color: #ffffff;
- outline: none;
- padding: 12px 40px 10px;
- position: relative;
-}
-.button:before,
-.button:after {
- border: 0 solid transparent;
- transition: all 0.25s;
- content: '';
- height: 24px;
- 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%;
- width: 100%;
-}
- Demo Explanation Use the :before and :after pseduo-elements as borders that animate on hover.
Browser support Calc() other The function calc() allows to define CSS values with the use of mathematical expressions, the value adopted for the property is the result of a mathematical expression.
HTML <div class="box-example"></div>
- CSS .box-example {
- height: 280px;
- background: #222 url('https://image.ibb.co/fUL9nS/wolf.png') no-repeat;
- background-position: calc(100% - 20px) calc(100% - 20px);
-}
- Demo If you want to align a background-image from right and bottom wasn't possible with just straight length values. So now it's possible using calc():
Background-image in the right/bottom
Explanation It allows addition, subtraction, multiplication and division. Can use different units (pixel and percent together, for example) for each value in your expression. It is permitted to nest calc() functions. It can be used in any property that <length>, <frequency>, <angle>, <time>, <number>, <color>, or <integer> is allowed, like width, height, font-size, top, left, etc. Browser support Circle visual Creates a circle shape with pure CSS.
HTML <div class="circle"></div>
- CSS .circle {
- border-radius: 50%;
- width: 2rem;
- height: 2rem;
- background: #333;
-}
- Demo Explanation border-radius: 50% curves the borders of an element to create a circle.
Since a circle has the same radius at any given point, the width and height must be the same. Differing values will create an ellipse.
Browser support Clearfix layout Ensures that an element self-clears its children.
Note: This is only useful if you are still using float to build layouts. Please consider using a modern approach with flexbox layout or grid layout. HTML <div class="clearfix">
- <div class="floated">float a</div>
- <div class="floated">float b</div>
- <div class="floated">float c</div>
-</div>
- CSS .clearfix::after {
- content: '';
- display: block;
- clear: both;
-}
-.floated {
- float: left;
-}
- Demo Explanation .clearfix::after defines a pseudo-element. content: '' allows the pseudo-element to affect layout. clear: both indicates that the left, right or both sides of the element cannot be adjacent to earlier floated elements within the same block formatting context. Browser support ⚠️ For this snippet to work properly you need to ensure that there are no non-floating children in the container and that there are no tall floats before the clearfixed container but in the same formatting context (e.g. floated columns).
Constant width to height ratio 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).
HTML <div class="constant-width-to-height-ratio"></div>
- CSS .constant-width-to-height-ratio {
- 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;
- clear: both;
-}
- Demo Explanation padding-top on the ::before pseudo-element causes the height of the element to equal a percentage of its width. 100% therefore means the element's height will always be 100% of the width, creating a responsive square.
This method also allows content to be placed inside the element normally.
Browser support Counter visual other Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.
HTML <ul>
- <li>List item</li>
- <li>List item</li>
- <li>
- List item
- <ul>
- <li>List item</li>
- <li>List item</li>
- <li>List item</li>
- </ul>
- </li>
-</ul>
- CSS ul {
- counter-reset: counter;
-}
-li::before {
- counter-increment: counter;
- content: counters(counter, '.') ' ';
-}
- Demo List item List item List item List item List item List item Explanation You can create a ordered list using any type of HTML.
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.
counter-increment Used in element that will be countable. Once counter-reset initialized, a counter's value can be increased or decreased.
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).
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).
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 Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms.
HTML <div class="custom-scrollbar">
- <p>
- 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 />
- Quisquam enim qui iure, consequatur velit sit?
- </p>
-</div>
- CSS .custom-scrollbar {
- height: 70px;
- overflow-y: scroll;
-}
-/* To style the document scrollbar, remove `.custom-scrollbar` */
-.custom-scrollbar::-webkit-scrollbar {
- width: 8px;
-}
-.custom-scrollbar::-webkit-scrollbar-track {
- box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
- border-radius: 10px;
-}
-.custom-scrollbar::-webkit-scrollbar-thumb {
- border-radius: 10px;
- box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
-}
- Demo Explanation ::-webkit-scrollbar targets the whole scrollbar element. ::-webkit-scrollbar-track targets only the scrollbar track. ::-webkit-scrollbar-thumb targets the scrollbar thumb. There are many other pseudo-elements that you can use to style scrollbars. For more info, visit the WebKit Blog .
Browser support ⚠️ Scrollbar styling doesn't appear to be on any standards track.
Custom text selection visual Changes the styling of text selection.
HTML <p class="custom-text-selection">Select some of this text.</p>
- CSS ::selection {
- background: aquamarine;
- color: black;
-}
-.custom-text-selection::selection {
- background: deeppink;
- color: white;
-}
- Demo Select some of this text.
Explanation ::selection defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element.
Browser support ⚠️ Requires prefixes for full support and is not actually in any specification.
Custom variables other CSS variables that contain specific values to be reused throughout a document.
HTML <p class="custom-variables">CSS is awesome!</p>
- CSS :root {
- /* Place variables within here to use the variables globally. */
-}
-.custom-variables {
- --some-color: #da7800;
- --some-keyword: italic;
- --some-size: 1.25em;
- --some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray, 0 0 0.2em slategray;
- color: var(--some-color);
- font-size: var(--some-size);
- font-style: var(--some-keyword);
- text-shadow: var(--some-complex-value);
-}
- Demo Explanation The variables are defined globally within the :root CSS pseudo-class which matches the root element of a tree representing the document. Variables can also be scoped to a selector if defined within the block.
Declare a variable with --variable-name:.
Reuse variables throughout the document using the var(--variable-name) function.
Browser support Disable selection interactivity Makes the content unselectable.
HTML <p>You can select me.</p>
-<p class="unselectable">You can't select me!</p>
- CSS .unselectable {
- user-select: none;
-}
- Demo You can select me.
You can't select me!
Explanation user-select: none specifies that the text cannot be selected.
Browser support ⚠️ Requires prefixes for full support. ⚠️ This is not a secure method to prevent users from copying content.
Display table centering layout Vertically and horizontally centers a child element within its parent element using display: table (as an alternative to flexbox).
HTML <div class="container">
- <div class="center"><span>Centered content</span></div>
-</div>
- CSS .container {
- border: 1px solid #333;
- height: 250px;
- width: 250px;
-}
-.center {
- display: table;
- height: 100%;
- width: 100%;
-}
-.center > span {
- display: table-cell;
- text-align: center;
- vertical-align: middle;
-}
- Demo Explanation display: table on '.center' allows the element to behave like a <table> HTML element. 100% height and width on '.center' allows the element to fill the available space within its parent element. display: table-cell on '.center > span' allows the element to behave like an HTML element. text-align: center on '.center > span' centers the child element horizontally. vertical-align: middle on '.center > span' centers the child element vertically. The outer parent ('.container' in this case) must have a fixed height and width.
Browser support Donut spinner animation Creates a donut spinner that can be used to indicate the loading of content.
HTML <div class="donut"></div>
- CSS @keyframes donut-spin {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(360deg);
- }
-}
-.donut {
- display: inline-block;
- border: 4px solid rgba(0, 0, 0, 0.1);
- border-left-color: #7983ff;
- border-radius: 50%;
- width: 30px;
- height: 30px;
- animation: donut-spin 1.2s linear infinite;
-}
- Demo Explanation Use a semi-transparent border for the whole element, except one side that will serve as the loading indicator for the donut. Use animation to rotate the element.
Browser support ⚠️ Requires prefixes for full support.
Dynamic shadow visual Creates a shadow similar to box-shadow but based on the colors of the element itself.
HTML <div class="dynamic-shadow"></div>
- CSS .dynamic-shadow {
- position: relative;
- width: 10rem;
- height: 10rem;
- background: linear-gradient(75deg, #6d78ff, #00ffb8);
- z-index: 1;
-}
-.dynamic-shadow::after {
- content: '';
- width: 100%;
- height: 100%;
- position: absolute;
- background: inherit;
- top: 0.5rem;
- filter: blur(0.4rem);
- opacity: 0.7;
- z-index: -1;
-}
- Demo Explanation position: relative on the element establishes a Cartesian positioning context for psuedo-elements. z-index: 1 establishes a new stacking context. ::after defines a pseudo-element. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent. width: 100% and height: 100% sizes the pseudo-element to fill its parent's dimensions, making it equal in size. background: inherit causes the pseudo-element to inherit the linear gradient specified on the element. top: 0.5rem offsets the pseudo-element down slightly from its parent. filter: blur(0.4rem) will blur the pseudo-element to create the appearance of a shadow underneath. opacity: 0.7 makes the pseudo-element partially transparent. z-index: -1 positions the pseudo-element behind the parent but in front of the background. Browser support ⚠️ Requires prefixes for full support.
Easing variables animation 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>
- CSS :root {
- /* Place variables in here to use globally */
-}
-.easing-variables {
- --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
- --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
- --ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
- --ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
- --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
- --ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
- --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
- --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
- --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
- --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
- --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
- --ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);
- --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);
- --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);
- --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);
- --ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1);
- --ease-in-out-expo: cubic-bezier(1, 0, 0, 1);
- --ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.15, 0.86);
- display: inline-block;
- width: 75px;
- height: 75px;
- padding: 10px;
- color: white;
- line-height: 50px;
- text-align: center;
- background: #333;
- transition: transform 1s var(--ease-out-quart);
-}
-.easing-variables:hover {
- transform: rotate(45deg);
-}
- Demo Explanation The variables are defined globally within the :root CSS pseudo-class which matches the root element of a tree representing the document. In HTML, :root represents the <html> element and is identical to the selector html, except that its specificity is higher.
Browser support Etched text visual Creates an effect where text appears to be "etched" or engraved into the background.
HTML <p class="etched-text">I appear etched into the background.</p>
- CSS .etched-text {
- text-shadow: 0 2px white;
- font-size: 1.5rem;
- font-weight: bold;
- color: #b8bec5;
-}
- Demo I appear etched into the background.
Explanation text-shadow: 0 2px white creates a white shadow offset 0px horizontally and 2px vertically from the origin position.
The background must be darker than the shadow for the effect to work.
The text color should be slightly faded to make it look like it's engraved/carved out of the background.
Browser support Evenly distributed children layout Evenly distributes child elements within a parent element.
HTML <div class="evenly-distributed-children">
- <p>Item1</p>
- <p>Item2</p>
- <p>Item3</p>
-</div>
- CSS .evenly-distributed-children {
- display: flex;
- justify-content: space-between;
-}
- Demo Explanation display: flex enables flexbox. 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.
Browser support ⚠️ Needs prefixes for full support.
Fit image in container layout visual Changes the fit and position of an image within its container while preserving its aspect ratio. Previously only possible using a background image and the background-size property.
HTML <img class="image image-contain" src="https://picsum.photos/600/200" />
-<img class="image image-cover" src="https://picsum.photos/600/200" />
- CSS .image {
- background: #34495e;
- border: 1px solid #34495e;
- width: 200px;
- height: 200px;
-}
-.image-contain {
- object-fit: contain;
- object-position: center;
-}
-.image-cover {
- object-fit: cover;
- object-position: right top;
-}
- Demo Explanation object-fit: contain fits the entire image within the container while preserving its aspect ratio. object-fit: cover fills the container with the image while preserving its aspect ratio. object-position: [x] [y] positions the image within the container. Browser support Flexbox centering layout Horizontally and vertically centers a child element within a parent element using flexbox.
HTML <div class="flexbox-centering"><div class="child">Centered content.</div></div>
- CSS .flexbox-centering {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100px;
-}
- Demo Explanation display: flex enables flexbox. justify-content: center centers the child horizontally. align-items: center centers the child vertically. Browser support ⚠️ Needs prefixes for full support.
Focus Within visual interactivity Changes the appearance of a form if any of its children are focused.
HTML <div class="focus-within">
- <form>
- <label for="given_name">Given Name:</label> <input id="given_name" type="text" /> <br />
- <label for="family_name">Family Name:</label> <input id="family_name" type="text" />
- </form>
-</div>
- CSS form {
- border: 3px solid #2d98da;
- color: #000000;
- padding: 4px;
-}
-form:focus-within {
- background: #f7b731;
- color: #000000;
-}
- Demo 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.
Browser support ⚠️ Not supported in IE11 or the current version of Edge.
Fullscreen visual The :fullscreen CSS pseudo-class represents an element that's displayed when the browser is in fullscreen mode.
HTML <div class="container">
- <p><em>Click the button below to enter the element into fullscreen mode. </em></p>
- <div class="element" id="element"><p>I change color in fullscreen mode!</p></div>
- <br />
- <button onclick="var el = document.getElementById('element'); el.requestFullscreen();">
- Go Full Screen!
- </button>
-</div>
- CSS .container {
- margin: 40px auto;
- max-width: 700px;
-}
-.element {
- padding: 20px;
- height: 300px;
- width: 100%;
- background-color: skyblue;
-}
-.element p {
- text-align: center;
- color: white;
- font-size: 3em;
-}
-.element:-ms-fullscreen p {
- visibility: visible;
-}
-.element:fullscreen {
- background-color: #e4708a;
- width: 100vw;
- height: 100vh;
-}
- Demo Click the button below to enter the element into fullscreen mode.
I change color in fullscreen mode!
Go Full Screen! Explanation fullscreen CSS pseudo-class selector is used to select and style an element that is being displayed in fullscreen mode. Browser support Ghost trick layout Vertically centers an element in another.
HTML <div class="ghost-trick">
- <div class="ghosting"><p>Vertically centered without changing the position property.</p></div>
-</div>
- CSS .ghosting {
- height: 300px;
- background: #0ff;
-}
-.ghosting:before {
- content: '';
- display: inline-block;
- height: 100%;
- vertical-align: middle;
-}
-p {
- display: inline-block;
- vertical-align: middle;
-}
- Demo Vertically centered without changing the position property.
Explanation Use the style of a :before pseudo-element to vertically align inline elements without changing their position property.
Browser support Gradient text visual Gives text a gradient color.
HTML <p class="gradient-text">Gradient text</p>
- CSS .gradient-text {
- background: -webkit-linear-gradient(pink, red);
- -webkit-text-fill-color: transparent;
- -webkit-background-clip: text;
-}
- Demo Explanation background: -webkit-linear-gradient(...) gives the text element a gradient background. webkit-text-fill-color: transparent fills the text with a transparent color. webkit-background-clip: text clips the background with the text, filling the text with the gradient background as the color. Browser support ⚠️ Uses non-standard properties.
Grid centering layout 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>
- CSS .grid-centering {
- display: grid;
- justify-content: center;
- align-items: center;
- height: 100px;
-}
- Demo Explanation display: grid enables grid. justify-content: center centers the child horizontally. align-items: center centers the child vertically. Browser support Hairline border visual 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>
- CSS .hairline-border {
- box-shadow: 0 0 0 1px;
-}
-@media (min-resolution: 2dppx) {
- .hairline-border {
- box-shadow: 0 0 0 0.5px;
- }
-}
-@media (min-resolution: 3dppx) {
- .hairline-border {
- box-shadow: 0 0 0 0.33333333px;
- }
-}
-@media (min-resolution: 4dppx) {
- .hairline-border {
- box-shadow: 0 0 0 0.25px;
- }
-}
- Demo Explanation box-shadow, when only using spread, adds a pseudo-border which can use subpixels*. 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 ⚠️ Needs alternate syntax and JavaScript user agent checking for full support.
*Chrome does not support subpixel values on border. Safari does not support subpixel values on box-shadow. Firefox supports subpixel values on both.
Height transition animation Transitions an element's height from 0 to auto when its height is unknown.
HTML <div class="trigger">
- Hover me to see a height transition.
- <div class="el">content</div>
-</div>
- CSS .el {
- transition: max-height 0.5s;
- overflow: hidden;
- max-height: 0;
-}
-.trigger:hover > .el {
- max-height: var(--max-height);
-}
- JavaScript var el = document.querySelector('.el')
-var height = el.scrollHeight
-el.style.setProperty('--max-height', height + 'px')
- Demo Hover me to see a height transition.
content
Explanation CSS transition: max-height: 0.5s cubic-bezier(...) specifies that changes to max-height should be transitioned over 0.5 seconds, using an ease-out-quint timing function. overflow: hidden prevents the contents of the hidden element from overflowing its container. max-height: 0 specifies that the element has no height initially. .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. JavaScript el.scrollHeight is the height of the element including overflow, which will change dynamically based on the content of the element. 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. 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.
Hover shadow box animation animation Creates a shadow box around the text when it is hovered.
HTML <p class="hover-shadow-box-animation">Box it!</p>
- CSS .hover-shadow-box-animation {
- display: inline-block;
- vertical-align: middle;
- transform: perspective(1px) translateZ(0);
- box-shadow: 0 0 1px transparent;
- margin: 10px;
- transition-duration: 0.3s;
- transition-property: box-shadow, transform;
-}
-.hover-shadow-box-animation:hover,
-.hover-shadow-box-animation:focus,
-.hover-shadow-box-animation:active {
- box-shadow: 1px 10px 10px -10px rgba(0, 0, 24, 0.5);
- transform: scale(1.2);
-}
- Demo Explanation display: inline-block to set width and length for p element thus making it an inline-block. Set transform: perspective(1px) to give element a 3D space by affecting the distance between the Z plane and the user and translate(0) to reposition the p element along z-axis in 3D space. box-shadow: to set up the box. transparent to make box transparent. transition-property to enable transitions for both box-shadow and transform. :hover to activate whole css when hovering is done until active. transform: scale(1.2) to change the scale, magnifying the text. Browser Support Hover underline animation animation Creates an animated underline effect when the text is hovered over.
Credit: https://flatuicolors.com/
HTML <p class="hover-underline-animation">Hover this text to see the effect!</p>
- CSS .hover-underline-animation {
- display: inline-block;
- position: relative;
- color: #0087ca;
-}
-.hover-underline-animation::after {
- content: '';
- position: absolute;
- width: 100%;
- transform: scaleX(0);
- height: 2px;
- bottom: 0;
- left: 0;
- background-color: #0087ca;
- transform-origin: bottom right;
- transition: transform 0.25s ease-out;
-}
-.hover-underline-animation:hover::after {
- transform: scaleX(1);
- transform-origin: bottom left;
-}
- Demo Hover this text to see the effect!
Explanation display: inline-block makes the block p an inline-block to prevent the underline from spanning the entire parent width rather than just the content (text). position: relative on the element establishes a Cartesian positioning context for pseudo-elements. ::after defines a pseudo-element. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent. width: 100% ensures the pseudo-element spans the entire width of the text block. transform: scaleX(0) initially scales the pseudo element to 0 so it has no width and is not visible. bottom: 0 and left: 0 position it to the bottom left of the block. transition: transform 0.25s ease-out means changes to transform will be transitioned over 0.25 seconds with an ease-out timing function. transform-origin: bottom right means the transform anchor point is positioned at the bottom right of the block. :hover::after then uses scaleX(1) to transition the width to 100%, then changes the transform-origin to bottom left so that the anchor point is reversed, allowing it transition out in the other direction when hovered off. Browser support Last item with remaining available height layout Take advantage of available viewport space by giving the last element the remaining available space in current viewport, even when resizing the window.
HTML <div class="container">
- <div>Div 1</div>
- <div>Div 2</div>
- <div>Div 3</div>
-</div>
- CSS html,
-body {
- height: 100%;
- margin: 0;
-}
-.container {
- height: 100%;
- display: flex;
- flex-direction: column;
-}
-.container > div:last-child {
- background-color: tomato;
- flex: 1;
-}
- Demo Explanation height: 100% set the height of container as viewport height. display: flex enables flexbox. flex-direction: column set the direction of flex items' order from top to down. 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.
Browser support ⚠️ Needs prefixes for full support.
Mouse cursor gradient tracking visual interactivity A hover effect where the gradient follows the mouse cursor.
Credit: Tobias Reich
HTML <button class="mouse-cursor-gradient-tracking"><span>Hover me</span></button>
- CSS .mouse-cursor-gradient-tracking {
- position: relative;
- background: #7983ff;
- padding: 0.5rem 1rem;
- font-size: 1.2rem;
- border: none;
- color: white;
- cursor: pointer;
- outline: none;
- overflow: hidden;
-}
-.mouse-cursor-gradient-tracking span {
- position: relative;
-}
-.mouse-cursor-gradient-tracking::before {
- --size: 0;
- content: '';
- position: absolute;
- left: var(--x);
- top: var(--y);
- width: var(--size);
- height: var(--size);
- background: radial-gradient(circle closest-side, pink, transparent);
- transform: translate(-50%, -50%);
- transition: width 0.2s ease, height 0.2s ease;
-}
-.mouse-cursor-gradient-tracking:hover::before {
- --size: 200px;
-}
- JavaScript var btn = document.querySelector('.mouse-cursor-gradient-tracking')
-btn.onmousemove = function(e) {
- var x = e.pageX - btn.offsetLeft - btn.offsetParent.offsetLeft
- var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop
- btn.style.setProperty('--x', x + 'px')
- btn.style.setProperty('--y', y + 'px')
-}
- Demo Hover me
Explanation TODO
Browser support
Requires JavaScript
⚠️ Requires JavaScript.
:not selector visual The :not psuedo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.
HTML <ul class="css-not-selector-shortcut">
- <li>One</li>
- <li>Two</li>
- <li>Three</li>
- <li>Four</li>
-</ul>
- CSS .css-not-selector-shortcut {
- display: flex;
-}
-ul {
- padding-left: 0;
-}
-li {
- list-style-type: none;
- margin: 0;
- padding: 0 0.75rem;
-}
-li:not(:last-child) {
- border-right: 2px solid #d2d5e4;
-}
- Demo Explanation li:not(:last-child) specifies that the styles should apply to all li elements except the :last-child.
Browser support Offscreen layout visual 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 ) 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.
HTML <a class="button" href="http://pantswebsite.com">
- Learn More <span class="offscreen"> about pants</span>
-</a>
- CSS .offscreen {
- border: 0;
- clip: rect(0 0 0 0);
- height: 1px;
- margin: -1px;
- overflow: hidden;
- padding: 0;
- position: absolute;
- width: 1px;
-}
- Demo Explanation Remove all borders. Use clip to indicate that no part of the element should be shown. Make the height and width of the element 1px. Negate the elements height and width using margin: -1px. Hide the element's overflow. Remove all padding. Position the element absolutely so that it does not take up space in the DOM. Browser support (Although clip technically has been depreciated, the newer clip-path currently has very limited browser support.)
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">
- 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 />
- Quisquam enim qui iure, consequatur velit sit? <br />
- 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 />
- Quisquam enim qui iure, consequatur velit sit?
- </div>
-</div>
- CSS .overflow-scroll-gradient {
- position: relative;
-}
-.overflow-scroll-gradient::after {
- content: '';
- position: absolute;
- bottom: 0;
- width: 240px;
- height: 25px;
- background: linear-gradient(
- rgba(255, 255, 255, 0.001),
- white
- ); /* transparent keyword is broken in Safari */
- pointer-events: none;
-}
-.overflow-scroll-gradient__scroller {
- overflow-y: scroll;
- background: white;
- width: 240px;
- height: 200px;
- padding: 15px;
- line-height: 1.2;
-}
- Demo Explanation position: relative on the parent establishes a Cartesian positioning context for pseudo-elements. ::after defines a pseudo element. background-image: linear-gradient(...) adds a linear gradient that fades from transparent to white (top to bottom). position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent. width: 240px matches the size of the scrolling element (which is a child of the parent that has the pseudo element). height: 25px is the height of the fading gradient pseudo-element, which should be kept relatively small. bottom: 0 positions the pseudo-element at the bottom of the parent. pointer-events: none specifies that the pseudo-element cannot be a target of mouse events, allowing text behind it to still be selectable/interactive. Browser support Reveals an interactive popout menu on hover and focus.
HTML <div class="reference" tabindex="0"><div class="popout-menu">Popout menu</div></div>
- CSS .reference {
- position: relative;
- background: tomato;
- width: 100px;
- height: 100px;
-}
-.popout-menu {
- position: absolute;
- visibility: hidden;
- left: 100%;
- background: #333;
- color: white;
- padding: 15px;
-}
-.reference:hover > .popout-menu,
-.reference:focus > .popout-menu,
-.reference:focus-within > .popout-menu {
- visibility: visible;
-}
- Demo Explanation position: relative on the reference parent establishes a Cartesian positioning context for its child. position: absolute takes the popout menu out of the flow of the document and positions it in relation to the parent. left: 100% moves the the popout menu 100% of its parent's width from the left. visibility: hidden hides the popout menu initially and allows for transitions (unlike display: none). .reference:hover > .popout-menu means that when .reference is hovered over, select immediate children with a class of .popout-menu and change their visibility to visible, which shows the popout. .reference:focus > .popout-menu means that when .reference is focused, the popout would be shown. .reference:focus-within > .popout-menu ensures that the popout is shown when the focus is within the reference. Browser support Pretty text underline visual A nicer alternative to text-decoration: underline or <u></u> where descenders do not clip the underline. Natively implemented as text-decoration-skip-ink: auto but it has less control over the underline.
HTML <p class="pretty-text-underline">Pretty text underline without clipping descending letters.</p>
- CSS .pretty-text-underline {
- display: inline;
- text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;
- background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);
- background-position: bottom;
- 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;
-}
- Demo Pretty text underline without clipping descending letters.
Explanation text-shadow uses 4 values with offsets that cover a 4x4 px area to ensure the underline has a "thick" shadow that covers the line where descenders clip it. Use a color that matches the background. For a larger font, use a larger px size. Additional values can create an even thicker shadow, and subpixel values can also be used. background-image: linear-gradient(...) creates a 90deg gradient using the text color (currentColor). The background-* properties size the gradient as 100% of the width of the block and 1px in height at the bottom and disables repetition, which creates a 1px underline beneath the text. The ::selection pseudo selector rule ensures the text shadow does not interfere with text selection. Browser support Reset all styles visual Resets all styles to default values with one property. This will not affect direction and unicode-bidi properties.
HTML <div class="reset-all-styles">
- <h5>Title</h5>
- <p>
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui
- repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui
- iure, consequatur velit sit?
- </p>
-</div>
- CSS .reset-all-styles {
- all: initial;
-}
- Demo Title Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui iure, consequatur velit sit?
Explanation The all property allows you to reset all styles (inherited or not) to default values.
Browser support ⚠️ MS Edge status is under consideration.
Shape separator visual Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.
HTML <div class="shape-separator"></div>
- CSS .shape-separator {
- position: relative;
- 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");
- position: absolute;
- width: 100%;
- height: 12px;
- bottom: 0;
-}
- Demo Explanation position: relative on the element establishes a Cartesian positioning context for pseudo elements. ::after defines a pseudo element. background-image: url(...) adds the SVG shape (a 24x12 triangle) as the background image of the pseudo element, which repeats by default. It must be the same color as the block that is being separated. For other shapes, we can use the URL-encoder for SVG . position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent. width: 100% ensures the element stretches the entire width of its parent. height: 12px is the same height as the shape. bottom: 0 positions the pseudo element at the bottom of the parent. Browser support Sibling fade interactivity Fades out the siblings of a hovered item.
HTML <div class="sibling-fade">
- <span>Item 1</span> <span>Item 2</span> <span>Item 3</span> <span>Item 4</span>
- <span>Item 5</span> <span>Item 6</span>
-</div>
- CSS span {
- padding: 0 1rem;
- transition: opacity 0.2s;
-}
-.sibling-fade:hover span:not(:hover) {
- opacity: 0.5;
-}
- Demo Item 1 Item 2 Item 3 Item 4 Item 5 Item 6
Explanation transition: opacity 0.2s specifies that changes to opacity will be transitioned over 0.2 seconds. .sibling-fade:hover span:not(:hover) specifies that when the parent is hovered, select any span children that are not currently being hovered and change their opacity to 0.5. Browser support System font stack visual Uses the native font of the operating system to get close to a native app feel.
HTML <p class="system-font-stack">This text uses the system font.</p>
- CSS .system-font-stack {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,
- Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif;
-}
- Demo This text uses the system font.
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).
-apple-system is San Francisco, used on iOS and macOS (not Chrome however) BlinkMacSystemFont is San Francisco, used on macOS Chrome Segoe UI is used on Windows 10 Roboto is used on Android Oxygen-Sans is used on Linux with KDE Ubuntu is used on Ubuntu (all variants) Cantarell is used on Linux with GNOME Shell "Helvetica Neue" and Helvetica is used on macOS 10.10 and below (wrapped in quotes because it has a space) Arial is a font widely supported by all operating systems sans-serif is the fallback sans-serif font if none of the other fonts are supported Browser support Toggle switch visual interactivity Creates a toggle switch with CSS only.
HTML <input type="checkbox" id="toggle" class="offscreen" /> <label for="toggle" class="switch"></label>
- CSS .switch {
- position: relative;
- display: inline-block;
- width: 40px;
- height: 20px;
- background-color: rgba(0, 0, 0, 0.25);
- border-radius: 20px;
- transition: all 0.3s;
-}
-.switch::after {
- content: '';
- position: absolute;
- width: 18px;
- height: 18px;
- border-radius: 18px;
- background-color: white;
- top: 1px;
- left: 1px;
- transition: all 0.3s;
-}
-input[type='checkbox']:checked + .switch::after {
- transform: translateX(20px);
-}
-input[type='checkbox']:checked + .switch {
- background-color: #7983ff;
-}
-.offscreen {
- position: absolute;
- left: -9999px;
-}
- Demo
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.
The for attribute associates the <label> with the appropriate <input> checkbox element by its id. .switch::after defines a pseudo-element for the <label> to create the circular knob. input[type='checkbox']:checked + .switch::after targets the <label>'s pseudo-element's style when the checkbox is checked. transform: translateX(20px) moves the pseudo-element (knob) 20px to the right when the checkbox is checked. background-color: #7983ff; sets the background-color of the switch to a different color when the checkbox is checked. .offscreen moves the <input> checkbox element, which does not comprise any part of the actual toggle switch, out of the flow of document and positions it far away from the view, but does not hide it so it is accessible via keyboard and screen readers. transition: all 0.3s specifies all property changes will be transitioned over 0.3 seconds, therefore transitioning the <label>'s background-color and the pseudo-element's transform property when the checkbox is checked. Browser support ⚠️ Requires prefixes for full support.
Vertically and horizontally centers a child element within its parent element using position: absolute and transform: translate() (as an alternative to flexbox or display: table). Similar to flexbox, this method does not require you to know the height or width of your parent or child so it is ideal for responsive applications.
HTML <div class="parent"><div class="child">Centered content</div></div>
- CSS .parent {
- border: 1px solid #333;
- height: 250px;
- position: relative;
- width: 250px;
-}
-.child {
- left: 50%;
- position: absolute;
- top: 50%;
- transform: translate(-50%, -50%);
- text-align: center;
-}
- Demo Explanation position: absolute on the child element allows it to be positioned based on its containing block. left: 50% and top: 50% offsets the child 50% from the left and top edge of its containing block. transform: translate(-50%, -50%) allows the height and width of the child element to be negated so that it is vertically and horizontally centered. Note: Fixed height and width on parent element is for the demo only.
Browser support ⚠️ Requires prefix for full support.
Triangle visual Creates a triangle shape with pure CSS.
HTML <div class="triangle"></div>
- CSS .triangle {
- width: 0;
- height: 0;
- border-top: 20px solid #333;
- border-left: 20px solid transparent;
- border-right: 20px solid transparent;
-}
- Demo Explanation View this link for a detailed explanation.
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.
Browser support Truncate text multiline layout If the text is longer than one line, it will be truncated for n lines and end with an gradient fade.
HTML <p class="truncate-text-multiline">
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
- labore et.
-</p>
- CSS .truncate-text-multiline {
- overflow: hidden;
- display: block;
- height: 109.2px;
- margin: 0 auto;
- font-size: 26px;
- line-height: 1.4;
- width: 400px;
- position: relative;
-}
-.truncate-text-multiline:after {
- content: '';
- position: absolute;
- bottom: 0;
- right: 0;
- width: 150px;
- height: 36.4px;
- background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%);
-}
- Demo Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et.
Explanation overflow: hidden prevents the text from overflowing its dimensions (for a block, 100% width and auto height). width: 400px ensures the element has a dimension. height: 109.2px calculated value for height, it equals font-size * line-height * numberOfLines (in this case 26 * 1.4 * 3 = 109.2) height: 36.4px calculated value for gradient container, it equals font-size * line-height (in this case 26 * 1.4 = 36.4) background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%) gradient from transparent to #f5f6f9 Browser support Truncate text layout If the text is longer than one line, it will be truncated and end with an ellipsis ….
HTML <p class="truncate-text">If I exceed one line's width, I will be truncated.</p>
- CSS .truncate-text {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- width: 200px;
-}
- Demo If I exceed one line's width, I will be truncated.
Explanation overflow: hidden prevents the text from overflowing its dimensions (for a block, 100% width and auto height). white-space: nowrap prevents the text from exceeding one line in height. text-overflow: ellipsis makes it so that if the text exceeds its dimensions, it will end with an ellipsis. width: 200px; ensures the element has a dimension, to know when to get ellipsis Browser support ⚠️ Only works for single line elements.
Zebra striped list visual Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row.
HTML <ul>
- <li>Item 01</li>
- <li>Item 02</li>
- <li>Item 03</li>
- <li>Item 04</li>
- <li>Item 05</li>
-</ul>
- CSS li:nth-child(odd) {
- background-color: #eee;
-}
- Demo Item 01 Item 02 Item 03 Item 04 Item 05 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.
Browser support https://caniuse.com/#feat=css-sel3
\ No newline at end of file
diff --git a/docs/js.52a52df6.css b/docs/js.52a52df6.css
deleted file mode 100644
index 54083c3c3..000000000
--- a/docs/js.52a52df6.css
+++ /dev/null
@@ -1,9 +0,0 @@
-/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}[hidden],template{display:none}code[class*=language-],pre[class*=language-]{color:#d7ecff;background:none;font-family:Operator Mono,Roboto Mono,Menlo,Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:2;font-size:1rem;-webkit-overflow-scrolling:touch;margin:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-]::-moz-selection,code[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-]::selection,code[class*=language-] ::selection,pre[class*=language-]::selection,pre[class*=language-] ::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{overflow:auto;padding:.75rem 1.25rem}pre.is-option{margin:0;padding:0}:not(pre)>code[class*=language-],pre[class*=language-]{background:linear-gradient(-30deg,#273149,#1c273f);border-radius:.25rem}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#8ca2d3}.token.attr-name,.token.selector{color:#c7f683}.token.punctuation{color:#5ac8e3}.namespace{opacity:.7}.token.tag{color:#2cefd8}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol{color:#85b4ff}.language-css .token.string,.token.attr-value,.token.builtin,.token.char,.token.inserted,.token.string,.token.url{color:#ffd694}.style .token.string,.token.entity,.token.operator{color:#ff9bbe}.token.atrule,.token.important,.token.keyword{color:#b7adff}.token.function{color:#25d0e5}.token.regex,.token.variable{color:#00a8d4}.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}html{font-size:.95rem;box-sizing:border-box}*,:after,:before{box-sizing:inherit}body{font-family:-apple-system,BlinkMacSystemFont,Roboto,Segoe UI,Helvetica Neue,Helvetica,Arial,sans-serif;background:#f2f3f8;color:#324b64;line-height:1.5}a{color:#157bda;text-decoration:none;word-wrap:break-word;overflow-wrap:break-word}a:hover{color:#0090ff}hr{border:0;border-top:1px solid rgba(0,32,128,.1)}ol,ul{padding-left:1.25rem}.container{max-width:64rem;padding:0 2%;margin:0 auto}.main>.container{padding:0}@media (min-width:579px){.main>.container{padding:0 2%}}@media (min-width:768px){html{font-size:1rem}}@media (min-width:992px){.content-wrapper{margin-left:20%}}@media (min-width:1400px){.content-wrapper{margin-left:275px}}
-
-/*!
- * Hamburgers
- * @description Tasty CSS-animated hamburgers
- * @author Jonathan Suh @jonsuh
- * @site https://jonsuh.com/hamburgers
- * @link https://github.com/jonsuh/hamburgers
- */.hamburger{padding:1rem;display:inline-block;cursor:pointer;transition-property:opacity,filter;transition-duration:.15s;transition-timing-function:linear;font:inherit;color:inherit;text-transform:none;background-color:transparent;border:0;margin:0;overflow:visible;outline:0}.hamburger:hover{opacity:.7}.hamburger-box{width:40px;height:20px;display:inline-block;position:relative}.hamburger-inner{display:block;top:50%}.hamburger-inner,.hamburger-inner:after,.hamburger-inner:before{width:36px;height:2px;background-color:#e3f5ff;border-radius:4px;position:absolute;transition-property:transform;transition-duration:.15s;transition-timing-function:ease}.hamburger-inner:after,.hamburger-inner:before{content:"";display:block}.hamburger-inner:before{top:-10px}.hamburger-inner:after{bottom:-10px}.hamburger--3dx .hamburger-box{perspective:80px}.hamburger--3dx .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx .hamburger-inner:after,.hamburger--3dx .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx.is-active .hamburger-inner{background-color:transparent;transform:rotateY(180deg)}.hamburger--3dx.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dx.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dx-r .hamburger-box{perspective:80px}.hamburger--3dx-r .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx-r .hamburger-inner:after,.hamburger--3dx-r .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx-r.is-active .hamburger-inner{background-color:transparent;transform:rotateY(-180deg)}.hamburger--3dx-r.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dx-r.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dy .hamburger-box{perspective:80px}.hamburger--3dy .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy .hamburger-inner:after,.hamburger--3dy .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy.is-active .hamburger-inner{background-color:transparent;transform:rotateX(-180deg)}.hamburger--3dy.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dy.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dy-r .hamburger-box{perspective:80px}.hamburger--3dy-r .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy-r .hamburger-inner:after,.hamburger--3dy-r .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy-r.is-active .hamburger-inner{background-color:transparent;transform:rotateX(180deg)}.hamburger--3dy-r.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dy-r.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dxy .hamburger-box{perspective:80px}.hamburger--3dxy .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy .hamburger-inner:after,.hamburger--3dxy .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy.is-active .hamburger-inner{background-color:transparent;transform:rotateX(180deg) rotateY(180deg)}.hamburger--3dxy.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dxy.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dxy-r .hamburger-box{perspective:80px}.hamburger--3dxy-r .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy-r .hamburger-inner:after,.hamburger--3dxy-r .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy-r.is-active .hamburger-inner{background-color:transparent;transform:rotateX(180deg) rotateY(180deg) rotate(-180deg)}.hamburger--3dxy-r.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dxy-r.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--arrow.is-active .hamburger-inner:before{transform:translate3d(-8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrow.is-active .hamburger-inner:after{transform:translate3d(-8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--arrow-r.is-active .hamburger-inner:before{transform:translate3d(8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--arrow-r.is-active .hamburger-inner:after{transform:translate3d(8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowalt .hamburger-inner:before{transition:top .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt .hamburger-inner:after{transition:bottom .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt.is-active .hamburger-inner:before{top:0;transform:translate3d(-8px,-10px,0) rotate(-45deg) scaleX(.7);transition:top .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s}.hamburger--arrowalt.is-active .hamburger-inner:after{bottom:0;transform:translate3d(-8px,10px,0) rotate(45deg) scaleX(.7);transition:bottom .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s}.hamburger--arrowalt-r .hamburger-inner:before{transition:top .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt-r .hamburger-inner:after{transition:bottom .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt-r.is-active .hamburger-inner:before{top:0;transform:translate3d(8px,-10px,0) rotate(45deg) scaleX(.7);transition:top .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s}.hamburger--arrowalt-r.is-active .hamburger-inner:after{bottom:0;transform:translate3d(8px,10px,0) rotate(-45deg) scaleX(.7);transition:bottom .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s}.hamburger--arrowturn.is-active .hamburger-inner{transform:rotate(-180deg)}.hamburger--arrowturn.is-active .hamburger-inner:before{transform:translate3d(8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--arrowturn.is-active .hamburger-inner:after{transform:translate3d(8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowturn-r.is-active .hamburger-inner{transform:rotate(-180deg)}.hamburger--arrowturn-r.is-active .hamburger-inner:before{transform:translate3d(-8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowturn-r.is-active .hamburger-inner:after{transform:translate3d(-8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--boring .hamburger-inner,.hamburger--boring .hamburger-inner:after,.hamburger--boring .hamburger-inner:before{transition-property:none}.hamburger--boring.is-active .hamburger-inner{transform:rotate(45deg)}.hamburger--boring.is-active .hamburger-inner:before{top:0;opacity:0}.hamburger--boring.is-active .hamburger-inner:after{bottom:0;transform:rotate(-90deg)}.hamburger--collapse .hamburger-inner{top:auto;bottom:0;transition-duration:.13s;transition-delay:.13s;transition-timing-function:cubic-bezier(.55,.055,.675,.19)}.hamburger--collapse .hamburger-inner:after{top:-20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,opacity .1s linear}.hamburger--collapse .hamburger-inner:before{transition:top .12s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--collapse.is-active .hamburger-inner{transform:translate3d(0,-10px,0) rotate(-45deg);transition-delay:.22s;transition-timing-function:cubic-bezier(.215,.61,.355,1)}.hamburger--collapse.is-active .hamburger-inner:after{top:0;opacity:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),opacity .1s linear .22s}.hamburger--collapse.is-active .hamburger-inner:before{top:0;transform:rotate(-90deg);transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .16s,transform .13s cubic-bezier(.215,.61,.355,1) .25s}.hamburger--collapse-r .hamburger-inner{top:auto;bottom:0;transition-duration:.13s;transition-delay:.13s;transition-timing-function:cubic-bezier(.55,.055,.675,.19)}.hamburger--collapse-r .hamburger-inner:after{top:-20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,opacity .1s linear}.hamburger--collapse-r .hamburger-inner:before{transition:top .12s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--collapse-r.is-active .hamburger-inner{transform:translate3d(0,-10px,0) rotate(45deg);transition-delay:.22s;transition-timing-function:cubic-bezier(.215,.61,.355,1)}.hamburger--collapse-r.is-active .hamburger-inner:after{top:0;opacity:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),opacity .1s linear .22s}.hamburger--collapse-r.is-active .hamburger-inner:before{top:0;transform:rotate(90deg);transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .16s,transform .13s cubic-bezier(.215,.61,.355,1) .25s}.hamburger--elastic .hamburger-inner{top:2px;transition-duration:.275s;transition-timing-function:cubic-bezier(.68,-.55,.265,1.55)}.hamburger--elastic .hamburger-inner:before{top:10px;transition:opacity .125s ease .275s}.hamburger--elastic .hamburger-inner:after{top:20px;transition:transform .275s cubic-bezier(.68,-.55,.265,1.55)}.hamburger--elastic.is-active .hamburger-inner{transform:translate3d(0,10px,0) rotate(135deg);transition-delay:75ms}.hamburger--elastic.is-active .hamburger-inner:before{transition-delay:0s;opacity:0}.hamburger--elastic.is-active .hamburger-inner:after{transform:translate3d(0,-20px,0) rotate(-270deg);transition-delay:75ms}.hamburger--elastic-r .hamburger-inner{top:2px;transition-duration:.275s;transition-timing-function:cubic-bezier(.68,-.55,.265,1.55)}.hamburger--elastic-r .hamburger-inner:before{top:10px;transition:opacity .125s ease .275s}.hamburger--elastic-r .hamburger-inner:after{top:20px;transition:transform .275s cubic-bezier(.68,-.55,.265,1.55)}.hamburger--elastic-r.is-active .hamburger-inner{transform:translate3d(0,10px,0) rotate(-135deg);transition-delay:75ms}.hamburger--elastic-r.is-active .hamburger-inner:before{transition-delay:0s;opacity:0}.hamburger--elastic-r.is-active .hamburger-inner:after{transform:translate3d(0,-20px,0) rotate(270deg);transition-delay:75ms}.hamburger--emphatic{overflow:hidden}.hamburger--emphatic .hamburger-inner{transition:background-color .125s ease-in .175s}.hamburger--emphatic .hamburger-inner:before{left:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,left .125s ease-in .175s}.hamburger--emphatic .hamburger-inner:after{top:10px;right:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,right .125s ease-in .175s}.hamburger--emphatic.is-active .hamburger-inner{transition-delay:0s;transition-timing-function:ease-out;background-color:transparent}.hamburger--emphatic.is-active .hamburger-inner:before{left:-80px;top:-80px;transform:translate3d(80px,80px,0) rotate(45deg);transition:left .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s}.hamburger--emphatic.is-active .hamburger-inner:after{right:-80px;top:-80px;transform:translate3d(-80px,80px,0) rotate(-45deg);transition:right .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s}.hamburger--emphatic-r{overflow:hidden}.hamburger--emphatic-r .hamburger-inner{transition:background-color .125s ease-in .175s}.hamburger--emphatic-r .hamburger-inner:before{left:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,left .125s ease-in .175s}.hamburger--emphatic-r .hamburger-inner:after{top:10px;right:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,right .125s ease-in .175s}.hamburger--emphatic-r.is-active .hamburger-inner{transition-delay:0s;transition-timing-function:ease-out;background-color:transparent}.hamburger--emphatic-r.is-active .hamburger-inner:before{left:-80px;top:80px;transform:translate3d(80px,-80px,0) rotate(-45deg);transition:left .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s}.hamburger--emphatic-r.is-active .hamburger-inner:after{right:-80px;top:80px;transform:translate3d(-80px,-80px,0) rotate(45deg);transition:right .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s}.hamburger--minus .hamburger-inner:after,.hamburger--minus .hamburger-inner:before{transition:bottom .08s ease-out 0s,top .08s ease-out 0s,opacity 0s linear}.hamburger--minus.is-active .hamburger-inner:after,.hamburger--minus.is-active .hamburger-inner:before{opacity:0;transition:bottom .08s ease-out,top .08s ease-out,opacity 0s linear .08s}.hamburger--minus.is-active .hamburger-inner:before{top:0}.hamburger--minus.is-active .hamburger-inner:after{bottom:0}.hamburger--slider .hamburger-inner{top:2px}.hamburger--slider .hamburger-inner:before{top:10px;transition-property:transform,opacity;transition-timing-function:ease;transition-duration:.15s}.hamburger--slider .hamburger-inner:after{top:20px}.hamburger--slider.is-active .hamburger-inner{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--slider.is-active .hamburger-inner:before{transform:rotate(-45deg) translate3d(-5.71429px,-6px,0);opacity:0}.hamburger--slider.is-active .hamburger-inner:after{transform:translate3d(0,-20px,0) rotate(-90deg)}.hamburger--slider-r .hamburger-inner{top:2px}.hamburger--slider-r .hamburger-inner:before{top:10px;transition-property:transform,opacity;transition-timing-function:ease;transition-duration:.15s}.hamburger--slider-r .hamburger-inner:after{top:20px}.hamburger--slider-r.is-active .hamburger-inner{transform:translate3d(0,10px,0) rotate(-45deg)}.hamburger--slider-r.is-active .hamburger-inner:before{transform:rotate(45deg) translate3d(5.71429px,-6px,0);opacity:0}.hamburger--slider-r.is-active .hamburger-inner:after{transform:translate3d(0,-20px,0) rotate(90deg)}.hamburger--spin .hamburger-inner{transition-duration:.22s;transition-timing-function:cubic-bezier(.55,.055,.675,.19)}.hamburger--spin .hamburger-inner:before{transition:top .1s ease-in .25s,opacity .1s ease-in}.hamburger--spin .hamburger-inner:after{transition:bottom .1s ease-in .25s,transform .22s cubic-bezier(.55,.055,.675,.19)}.hamburger--spin.is-active .hamburger-inner{transform:rotate(225deg);transition-delay:.12s;transition-timing-function:cubic-bezier(.215,.61,.355,1)}.hamburger--spin.is-active .hamburger-inner:before{top:0;opacity:0;transition:top .1s ease-out,opacity .1s ease-out .12s}.hamburger--spin.is-active .hamburger-inner:after{bottom:0;transform:rotate(-90deg);transition:bottom .1s ease-out,transform .22s cubic-bezier(.215,.61,.355,1) .12s}.hamburger--spin-r .hamburger-inner{transition-duration:.22s;transition-timing-function:cubic-bezier(.55,.055,.675,.19)}.hamburger--spin-r .hamburger-inner:before{transition:top .1s ease-in .25s,opacity .1s ease-in}.hamburger--spin-r .hamburger-inner:after{transition:bottom .1s ease-in .25s,transform .22s cubic-bezier(.55,.055,.675,.19)}.hamburger--spin-r.is-active .hamburger-inner{transform:rotate(-225deg);transition-delay:.12s;transition-timing-function:cubic-bezier(.215,.61,.355,1)}.hamburger--spin-r.is-active .hamburger-inner:before{top:0;opacity:0;transition:top .1s ease-out,opacity .1s ease-out .12s}.hamburger--spin-r.is-active .hamburger-inner:after{bottom:0;transform:rotate(90deg);transition:bottom .1s ease-out,transform .22s cubic-bezier(.215,.61,.355,1) .12s}.hamburger--spring .hamburger-inner{top:2px;transition:background-color 0s linear .13s}.hamburger--spring .hamburger-inner:before{top:10px;transition:top .1s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--spring .hamburger-inner:after{top:20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--spring.is-active .hamburger-inner{transition-delay:.22s;background-color:transparent}.hamburger--spring.is-active .hamburger-inner:before{top:0;transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .15s,transform .13s cubic-bezier(.215,.61,.355,1) .22s;transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--spring.is-active .hamburger-inner:after{top:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),transform .13s cubic-bezier(.215,.61,.355,1) .22s;transform:translate3d(0,10px,0) rotate(-45deg)}.hamburger--spring-r .hamburger-inner{top:auto;bottom:0;transition-duration:.13s;transition-delay:0s;transition-timing-function:cubic-bezier(.55,.055,.675,.19)}.hamburger--spring-r .hamburger-inner:after{top:-20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,opacity 0s linear}.hamburger--spring-r .hamburger-inner:before{transition:top .1s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--spring-r.is-active .hamburger-inner{transform:translate3d(0,-10px,0) rotate(-45deg);transition-delay:.22s;transition-timing-function:cubic-bezier(.215,.61,.355,1)}.hamburger--spring-r.is-active .hamburger-inner:after{top:0;opacity:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),opacity 0s linear .22s}.hamburger--spring-r.is-active .hamburger-inner:before{top:0;transform:rotate(90deg);transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .15s,transform .13s cubic-bezier(.215,.61,.355,1) .22s}.hamburger--stand .hamburger-inner{transition:transform 75ms cubic-bezier(.55,.055,.675,.19) .15s,background-color 0s linear 75ms}.hamburger--stand .hamburger-inner:before{transition:top 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand .hamburger-inner:after{transition:bottom 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand.is-active .hamburger-inner{transform:rotate(90deg);background-color:transparent;transition:transform 75ms cubic-bezier(.215,.61,.355,1) 0s,background-color 0s linear .15s}.hamburger--stand.is-active .hamburger-inner:before{top:0;transform:rotate(-45deg);transition:top 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s}.hamburger--stand.is-active .hamburger-inner:after{bottom:0;transform:rotate(45deg);transition:bottom 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s}.hamburger--stand-r .hamburger-inner{transition:transform 75ms cubic-bezier(.55,.055,.675,.19) .15s,background-color 0s linear 75ms}.hamburger--stand-r .hamburger-inner:before{transition:top 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand-r .hamburger-inner:after{transition:bottom 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand-r.is-active .hamburger-inner{transform:rotate(-90deg);background-color:transparent;transition:transform 75ms cubic-bezier(.215,.61,.355,1) 0s,background-color 0s linear .15s}.hamburger--stand-r.is-active .hamburger-inner:before{top:0;transform:rotate(-45deg);transition:top 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s}.hamburger--stand-r.is-active .hamburger-inner:after{bottom:0;transform:rotate(45deg);transition:bottom 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s}.hamburger--squeeze .hamburger-inner{transition-duration:75ms;transition-timing-function:cubic-bezier(.55,.055,.675,.19)}.hamburger--squeeze .hamburger-inner:before{transition:top 75ms ease .12s,opacity 75ms ease}.hamburger--squeeze .hamburger-inner:after{transition:bottom 75ms ease .12s,transform 75ms cubic-bezier(.55,.055,.675,.19)}.hamburger--squeeze.is-active .hamburger-inner{transform:rotate(45deg);transition-delay:.12s;transition-timing-function:cubic-bezier(.215,.61,.355,1)}.hamburger--squeeze.is-active .hamburger-inner:before{top:0;opacity:0;transition:top 75ms ease,opacity 75ms ease .12s}.hamburger--squeeze.is-active .hamburger-inner:after{bottom:0;transform:rotate(-90deg);transition:bottom 75ms ease,transform 75ms cubic-bezier(.215,.61,.355,1) .12s}.hamburger--vortex .hamburger-inner{transition-duration:.2s;transition-timing-function:cubic-bezier(.19,1,.22,1)}.hamburger--vortex .hamburger-inner:after,.hamburger--vortex .hamburger-inner:before{transition-duration:0s;transition-delay:.1s;transition-timing-function:linear}.hamburger--vortex .hamburger-inner:before{transition-property:top,opacity}.hamburger--vortex .hamburger-inner:after{transition-property:bottom,transform}.hamburger--vortex.is-active .hamburger-inner{transform:rotate(765deg);transition-timing-function:cubic-bezier(.19,1,.22,1)}.hamburger--vortex.is-active .hamburger-inner:after,.hamburger--vortex.is-active .hamburger-inner:before{transition-delay:0s}.hamburger--vortex.is-active .hamburger-inner:before{top:0;opacity:0}.hamburger--vortex.is-active .hamburger-inner:after{bottom:0;transform:rotate(90deg)}.hamburger--vortex-r .hamburger-inner{transition-duration:.2s;transition-timing-function:cubic-bezier(.19,1,.22,1)}.hamburger--vortex-r .hamburger-inner:after,.hamburger--vortex-r .hamburger-inner:before{transition-duration:0s;transition-delay:.1s;transition-timing-function:linear}.hamburger--vortex-r .hamburger-inner:before{transition-property:top,opacity}.hamburger--vortex-r .hamburger-inner:after{transition-property:bottom,transform}.hamburger--vortex-r.is-active .hamburger-inner{transform:rotate(-765deg);transition-timing-function:cubic-bezier(.19,1,.22,1)}.hamburger--vortex-r.is-active .hamburger-inner:after,.hamburger--vortex-r.is-active .hamburger-inner:before{transition-delay:0s}.hamburger--vortex-r.is-active .hamburger-inner:before{top:0;opacity:0}.hamburger--vortex-r.is-active .hamburger-inner:after{bottom:0;transform:rotate(-90deg)}.sidebar{background:#273149;position:fixed;z-index:2;width:100%;height:44px;box-shadow:0 .25rem .5rem -.1rem rgba(0,32,128,.2)}.sidebar__menu{position:absolute;font-weight:700;border:none;text-align:left;text-transform:uppercase;left:0;top:0;padding:.75rem 1rem;outline:0}.sidebar__menu-icon{height:24px}.sidebar__links{background:#273149;transition:transform .6s cubic-bezier(.165,.84,.44,1);transform-origin:0 0;transform:rotateX(-90deg);visibility:hidden;opacity:0;overflow-y:auto;-webkit-overflow-scrolling:touch;max-height:378px;margin-top:44px;box-shadow:0 .25rem .5rem -.1rem rgba(0,32,128,.2);padding-bottom:1rem}.sidebar__links.is-active{transform:rotateX(0);visibility:visible;opacity:1}.sidebar__link{display:block;color:#e3f5ff;padding:.75rem 1.5rem .75rem .75rem;margin-right:-.75rem;transition:all .1s ease-out;border-left:2px solid #576a85;font-weight:500;font-size:.95rem}.sidebar__link:hover{color:#88f4ff;background:hsla(0,0%,100%,.1);border-color:pink}.sidebar__section{padding:0 .75rem}.sidebar__section-heading{text-transform:capitalize;color:#e3f5ff;margin-bottom:.5rem}.sidebar__new{width:1.25rem;vertical-align:middle;margin-right:.25rem}@media (min-width:992px){.sidebar{left:0;top:0;bottom:0;width:20%;height:100%;background:linear-gradient(-30deg,#273149,#1c273f);box-shadow:.4rem .4rem .8rem rgba(0,32,64,.1);overflow-y:auto;color:#fff}}@media (min-width:992px) and (min-width:1400px){.sidebar{width:275px}}@media (min-width:992px){.sidebar__links{background:none;box-shadow:none;visibility:visible;opacity:1;transform:rotateX(0);margin-top:0;max-height:none}.sidebar__menu{display:none}}html:not(.macOS) .sidebar::-webkit-scrollbar-track{background-color:rgba(0,0,0,.6)}html:not(.macOS) .sidebar::-webkit-scrollbar{width:10px;background-color:#505b76}html:not(.macOS) .sidebar::-webkit-scrollbar-thumb{background-color:#505b76}.header{position:relative;padding:5rem 1rem 4rem;background:#5b67ff;background:linear-gradient(25deg,#95e2ff,#5f79ff,#8ed5ff);color:#fff;margin-bottom:2rem;text-align:center;overflow:hidden;z-index:1}.header:before{width:150%;height:150%;top:0;opacity:.1;z-index:-1}.header:after,.header:before{content:"";position:absolute;left:0}.header:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='M12 0l12 12H0z' fill='%23f2f3f8'/%3E%3C/svg%3E");background-size:24px 24px;width:100%;height:24px;bottom:-7px;z-index:3}.header__content{position:relative;z-index:3}.header__logo{height:146px;user-select:none}.header__heading{font-weight:300;font-size:3rem;margin:1rem 0;line-height:1.2}.header__description{font-size:1.5rem;max-width:600px;margin:0 auto 2rem;font-weight:300;letter-spacing:.4px}.header__css{font-size:4rem;font-weight:700}.header__github-button-wrapper{height:28px}.header__github-button{color:#fff}.header__leaves{width:250px}#header__blob,.header__leaves{position:absolute;user-select:none}#header__blob{width:240px;left:-25px;top:50px}#header__leaves1{right:-100px;top:-50px}#header__leaves2{left:-250px;bottom:-100px;transform:rotate(235deg);z-index:2;width:400px}@media (min-width:1150px){#header__leaves2{left:-100px;transform:rotate(180deg)}#header__blob{left:50px;top:5px}}@media (min-width:579px){.header{padding:6rem 0 5rem}.header__heading{font-size:3.75rem}}@media (min-width:992px){.header{padding:2.5rem 0 5rem}}.snippet{position:relative;background:#fff;padding:2rem 5%;box-shadow:0 .4rem .8rem -.1rem rgba(0,32,128,.1),0 0 0 1px #f0f2f7;border-radius:.25rem;font-size:1.1rem;margin-bottom:1.5rem}.snippet h3{font-size:2rem;padding:.5rem 0;border-bottom:1px solid rgba(0,32,128,.1);margin-bottom:1.25rem;margin-top:0;line-height:1.3}.snippet h3 span:not(.snippet__tag){margin-right:.75rem}.snippet code:not([class*=lang]){background:#fcfaff;border:1px solid #e2ddff;color:#4b00da;border-radius:.15rem;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:.9rem;padding:.2rem .4rem;margin:0 .1rem}.snippet ol{margin-top:.5rem}.snippet ol>li{margin-bottom:.5rem}.snippet>p{margin-top:.5rem}.snippet h4{display:inline-block;margin:1rem 0 .5rem;font-size:1.1rem;line-height:2}.snippet h4[data-type]{background:#333;padding:0 .5rem;border-radius:3px;font-size:.9rem;text-transform:uppercase;border:1px solid #c6d6ea;border-bottom-color:#b3c9e3;background:#fff;box-shadow:0 .25rem .5rem -.1rem rgba(0,32,64,.15);background-repeat:no-repeat}.snippet h4[data-type=HTML]{color:#fff;border:none;background-image:linear-gradient(135deg,#ff4c9f,#ff7b74)}.snippet h4[data-type=CSS]{color:#fff;border:none;background-image:linear-gradient(135deg,#7983ff,#5f9de9)}.snippet h4[data-type=JavaScript]{color:#fff;border:none;background-image:linear-gradient(135deg,#ffb000,#f58818)}.snippet__browser-support{display:inline-block;font-size:2rem;font-weight:200;line-height:1;margin:.5rem 0}.snippet__subheading.is-html{color:#e22f70}.snippet__subheading.is-css{color:#0a91d4}.snippet__subheading.is-explanation{color:#4b00da}.snippet__support-note{color:#9fa5b5;font-weight:700}.snippet__requires-javascript{position:absolute;background:red;background:linear-gradient(145deg,#ff003b,#ff4b39);color:#fff;padding:.25rem .5rem;font-size:.9rem;transform:rotate(20deg);font-weight:700;top:1rem;right:0}.snippet__new{position:absolute;top:-1rem;left:50%;transform:translateX(-50%);width:3rem}.snippet-demo{background:#f5f6f9;border-radius:.25rem;padding:.75rem 1.25rem}.snippet-demo.is-distinct{background:linear-gradient(135deg,#ff4c9f,#ff7b74)}@media (min-width:768px){.snippet__requires-javascript{right:-.5rem}}.back-to-top-button{display:flex;justify-content:center;align-items:center;cursor:pointer;font-weight:700;background:#fff;width:4rem;height:4rem;position:fixed;right:2rem;bottom:2rem;border-radius:50%;user-select:none;box-shadow:0 .4rem .8rem -.1rem rgba(0,32,128,.15);transition:all .2s ease-out;visibility:hidden;opacity:0;z-index:1;border:1px solid rgba(0,32,128,.1);outline:0;color:inherit}.back-to-top-button:focus,.back-to-top-button:hover{transform:scale(1.1);box-shadow:0 .8rem 1.6rem -.2rem rgba(0,32,128,.15);color:#35a8ff}.back-to-top-button:focus{box-shadow:0 .8rem 1.6rem -.2rem rgba(0,32,128,.15),0 0 2px 2px #35a8ff;outline-style:none}.back-to-top-button.is-visible{visibility:visible;opacity:1}.back-to-top-button .feather{width:2rem;height:2rem}.tags{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;margin-bottom:1rem;padding:0 1rem}.tags,.tags__tag{position:relative}.tags__tag{display:inline-block;top:-1px;font-weight:700;font-size:.75rem;text-transform:uppercase;color:#8385aa;white-space:nowrap;border:1px solid #c8cbf2;border-radius:2px;vertical-align:middle;line-height:2;padding:0 .5rem;margin:0 .1rem;transition:all .1s ease-out;outline:0}.tags__tag.is-large{font-size:.95rem;border-radius:.2rem}.tags__tag.is-large .feather{top:-2px;width:18px;height:18px}.tags__tag .feather{vertical-align:middle;margin-right:.25rem;position:relative;top:-1px;width:14px;height:14px}.tags button.tags__tag{user-select:none;cursor:pointer;margin-bottom:1rem;margin-right:1rem;background:#fff}.tags button.tags__tag:hover{background:#8385aa;border-color:#8385aa;color:#fff}.tags button.tags__tag.focus-visible:focus{box-shadow:0 0 0 .25rem rgba(131,133,170,.5)}.tags button.tags__tag:active{box-shadow:inset 0 .1rem .1rem .1rem rgba(0,0,0,.2);background:#666894;border-color:#666894}.tags button.tags__tag.is-active{background:#7983ff;border-color:#7983ff;color:#fff}.tags button.tags__tag.is-active.focus-visible:focus{box-shadow:0 0 0 .25rem rgba(121,131,255,.5)}.btn{display:inline-block;position:relative;top:-1px;font-weight:700;font-size:.75rem;text-transform:uppercase;color:#8385aa;white-space:nowrap;border:1px solid #c8cbf2;border-radius:2px;vertical-align:middle;line-height:2;padding:0 .5rem;margin-right:.5rem;transition:all .1s ease-out;outline:0}.btn.is-large{font-size:.95rem;border-radius:.2rem}.btn.is-large .feather{top:-2px;width:18px;height:18px}.btn .feather{vertical-align:middle;margin-right:.25rem;position:relative;top:-1px;width:14px;height:14px}button.btn{user-select:none;cursor:pointer;margin-bottom:1rem;margin-right:1rem;background:#fff}button.btn:hover{background:#8385aa;border-color:#8385aa;color:#fff}button.btn.focus-visible:focus{box-shadow:0 0 0 .25rem rgba(131,133,170,.5)}button.btn:active{box-shadow:inset 0 .1rem .1rem .1rem rgba(0,0,0,.2);background:#666894;border-color:#666894}button.btn.is-active{background:#7983ff;border-color:#7983ff;color:#fff}button.btn.is-active.focus-visible:focus{box-shadow:0 0 0 .25rem rgba(121,131,255,.5)}button.btn.codepen-btn{margin-top:.5rem}
\ No newline at end of file
diff --git a/docs/js.8bafe4ae.js b/docs/js.8bafe4ae.js
deleted file mode 100644
index aa3577c38..000000000
--- a/docs/js.8bafe4ae.js
+++ /dev/null
@@ -1,32 +0,0 @@
-parcelRequire=function(e,r,n,t){var i="function"==typeof parcelRequire&&parcelRequire,o="function"==typeof require&&require;function u(n,t){if(!r[n]){if(!e[n]){var f="function"==typeof parcelRequire&&parcelRequire;if(!t&&f)return f(n,!0);if(i)return i(n,!0);if(o&&"string"==typeof n)return o(n);var c=new Error("Cannot find module '"+n+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[n][1][r]||r},p.cache={};var l=r[n]=new u.Module(n);e[n][0].call(l.exports,p,l,l.exports,this)}return r[n].exports;function p(e){return u(p.resolve(e))}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=r,u.parent=i,u.register=function(r,n){e[r]=[function(e,r){r.exports=n},{}]};for(var f=0;f=0?e():(t=!1,document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1))}(function(){var e=!0,t=!1,n=null,o={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function d(e){return!!(e&&e!==document&&"HTML"!==e.nodeName&&"BODY"!==e.nodeName&&"classList"in e&&"contains"in e.classList)}function i(e){e.classList.contains("focus-visible")||(e.classList.add("focus-visible"),e.setAttribute("data-focus-visible-added",""))}function s(t){e=!1}function u(){document.addEventListener("mousemove",a),document.addEventListener("mousedown",a),document.addEventListener("mouseup",a),document.addEventListener("pointermove",a),document.addEventListener("pointerdown",a),document.addEventListener("pointerup",a),document.addEventListener("touchmove",a),document.addEventListener("touchstart",a),document.addEventListener("touchend",a)}function a(t){"html"!==t.target.nodeName.toLowerCase()&&(e=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mousedown",a),document.removeEventListener("mouseup",a),document.removeEventListener("pointermove",a),document.removeEventListener("pointerdown",a),document.removeEventListener("pointerup",a),document.removeEventListener("touchmove",a),document.removeEventListener("touchstart",a),document.removeEventListener("touchend",a))}document.addEventListener("keydown",function(t){d(document.activeElement)&&i(document.activeElement),e=!0},!0),document.addEventListener("mousedown",s,!0),document.addEventListener("pointerdown",s,!0),document.addEventListener("touchstart",s,!0),document.addEventListener("focus",function(t){var n,s,u;d(t.target)&&(e||(n=t.target,s=n.type,"INPUT"==(u=n.tagName)&&o[s]&&!n.readOnly||"TEXTAREA"==u&&!n.readOnly||n.isContentEditable))&&i(t.target)},!0),document.addEventListener("blur",function(e){var o;d(e.target)&&(e.target.classList.contains("focus-visible")||e.target.hasAttribute("data-focus-visible-added"))&&(t=!0,window.clearTimeout(n),n=window.setTimeout(function(){t=!1,window.clearTimeout(n)},100),(o=e.target).hasAttribute("data-focus-visible-added")&&(o.classList.remove("focus-visible"),o.removeAttribute("data-focus-visible-added")))},!0),document.addEventListener("visibilitychange",function(n){"hidden"==document.visibilityState&&(t&&(e=!0),u())},!0),u(),document.body.classList.add("js-focus-visible")})});
-},{}],"9KIJ":[function(require,module,exports) {
-
-},{}],"HxJM":[function(require,module,exports) {
-var global = arguments[3];
-var e=arguments[3],t="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},a=function(){var e=/\blang(?:uage)?-([\w-]+)\b/i,a=0,n=t.Prism={manual:t.Prism&&t.Prism.manual,disableWorkerMessageHandler:t.Prism&&t.Prism.disableWorkerMessageHandler,util:{encode:function(e){return e instanceof r?new r(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&").replace(/e.length)return;if(!(w instanceof o)){if(f&&k!=t.length-1){if(d.lastIndex=v,!(N=d.exec(e)))break;for(var F=N.index+(h?N[1].length:0),x=N.index+N[0].length,A=k,S=v,j=t.length;A=(S+=t[A].length)&&(++k,v=S);if(t[k]instanceof o)continue;C=A-k,w=e.slice(v,S),N.index-=v}else{d.lastIndex=0;var N=d.exec(w),C=1}if(N){h&&(m=N[1]?N[1].length:0);x=(F=N.index+m)+(N=N[0].slice(m)).length;var P=w.slice(0,F),E=w.slice(x),O=[k,C];P&&(++k,v+=P.length,O.push(P));var $=new o(u,p?n.tokenize(N,p):N,y,N,f);if(O.push($),E&&O.push(E),Array.prototype.splice.apply(t,O),1!=C&&n.matchGrammar(e,t,a,k,v,!0,u),s)break}else if(s)break}}}}},tokenize:function(e,t,a){var r=[e],i=t.rest;if(i){for(var s in i)t[s]=i[s];delete t.rest}return n.matchGrammar(e,r,t,0,0,!1),r},hooks:{all:{},add:function(e,t){var a=n.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=n.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(t)}}},r=n.Token=function(e,t,a,n,r){this.type=e,this.content=t,this.alias=a,this.length=0|(n||"").length,this.greedy=!!r};if(r.stringify=function(e,t,a){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(a){return r.stringify(a,t,e)}).join("");var i={type:e.type,content:r.stringify(e.content,t,a),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:a};if(e.alias){var s="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,s)}n.hooks.run("wrap",i);var l=Object.keys(i.attributes).map(function(e){return e+'="'+(i.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+i.tag+' class="'+i.classes.join(" ")+'"'+(l?" "+l:"")+">"+i.content+""+i.tag+">"},!t.document)return t.addEventListener?(n.disableWorkerMessageHandler||t.addEventListener("message",function(e){var a=JSON.parse(e.data),r=a.language,i=a.code,s=a.immediateClose;t.postMessage(n.highlight(i,n.languages[r],r)),s&&t.close()},!1),t.Prism):t.Prism;var i=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return i&&(n.filename=i.src,n.manual||i.hasAttribute("data-manual")||("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(n.highlightAll):window.setTimeout(n.highlightAll,16):document.addEventListener("DOMContentLoaded",n.highlightAll))),t.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=a),void 0!==e&&(e.Prism=a),a.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/(^|[^\\])["']/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/?[\da-z]{1,8};/i},a.languages.markup.tag.inside["attr-value"].inside.entity=a.languages.markup.entity,a.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),a.languages.xml=a.languages.markup,a.languages.html=a.languages.markup,a.languages.mathml=a.languages.markup,a.languages.svg=a.languages.markup,a.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},a.languages.css.atrule.inside.rest=a.languages.css,a.languages.markup&&(a.languages.insertBefore("markup","tag",{style:{pattern:/(` +
- `${js ? `` : ''}`
+// Load static parts for the README file
+try {
+ startPart = fs.readFileSync(
+ path.join(STATIC_PARTS_PATH, 'README-start.md'),
+ 'utf8',
+ );
+ endPart = fs.readFileSync(
+ path.join(STATIC_PARTS_PATH, 'README-end.md'),
+ 'utf8',
+ );
+} catch (err) {
+ console.log(`${red('ERROR!')} During static part loading: ${err}`);
+ process.exit(1);
+}
- const markdown = marked(snippetData, { renderer }).replace(
- 'Demo ',
- `Demo ${demo}`
- )
- const snippetEl = createElement(`${markdown}
`)
- snippetContainer.append(snippetEl)
+// Create the output for the README file
+try {
+ const tags = util.prepTaggedData(
+ Object.keys(snippets).reduce((acc, key) => {
+ acc[key] = snippets[key].attributes.tags;
+ return acc;
+ }, {}),
+ );
- // browser support usage
- const featUsageShares = (snippetData.match(/https?:\/\/caniuse\.com\/#feat=.*/g) || []).map(
- feat => {
- const featData = caniuseDb.data[feat.match(/#feat=(.*)/)[1]]
- // caniuse doesn't count "untracked" users, which makes the overall share appear much lower
- // than it probably is. Most of these untracked browsers probably support these features.
- // Currently it's around 5.3% untracked, so we'll use 4% as probably supporting the feature.
- // Also the npm package appears to be show higher usage % than the main website, this shows
- // about 0.2% lower than the main website when selecting "tracked users" (as of Feb 2019).
- const UNTRACKED_PERCENT = 4
- const usage = featData
- ? Number(featData.usage_perc_y + featData.usage_perc_a) + UNTRACKED_PERCENT
- : 100
- return Math.min(100, usage)
+ output += `${startPart}\n`;
+
+ // Loop over tags and snippets to create the table of contents
+ for (const tag of tags) {
+ const capitalizedTag = util.capitalize(tag, true);
+ const taggedSnippets = snippetsArray.filter(
+ snippet => snippet.attributes.tags[0] === tag,
+ );
+ output += headers.h3((EMOJIS[tag] || '') + ' ' + capitalizedTag).trim();
+
+ output +=
+ misc.collapsible(
+ 'View contents',
+ lists.ul(taggedSnippets, snippet =>
+ misc.link(
+ `\`${snippet.title}\``,
+ `${misc.anchor(snippet.title)}${
+ snippet.attributes.tags.includes('advanced') ? '-' : ''
+ }`,
+ ),
+ ),
+ ) + '\n';
+ }
+
+ for (const tag of tags) {
+ const capitalizedTag = util.capitalize(tag, true);
+ const taggedSnippets = snippetsArray.filter(
+ snippet => snippet.attributes.tags[0] === tag,
+ );
+
+ output +=
+ misc.hr() + headers.h2((EMOJIS[tag] || '') + ' ' + capitalizedTag) + '\n';
+
+ for (let snippet of taggedSnippets) {
+ if (snippet.attributes.tags.includes('advanced'))
+ output +=
+ headers.h3(
+ snippet.title + ' ' + misc.image('advanced', '/advanced.svg'),
+ ) + '\n';
+ else output += headers.h3(snippet.title) + '\n';
+
+ output += snippet.attributes.text;
+
+ output += `\`\`\`${config.secondLanguage}\n${snippet.attributes.codeBlocks.html}\n\`\`\`\n\n`;
+ output += `\`\`\`${config.language}\n${snippet.attributes.codeBlocks.css}\n\`\`\`\n\n`;
+ if (snippet.attributes.codeBlocks.js)
+ output += `\`\`\`${config.optionalLanguage}\n${snippet.attributes.codeBlocks.js}\n\`\`\`\n\n`;
+
+ output += headers.h4('Explanation');
+ output += snippet.attributes.explanation;
+
+ output += headers.h4('Browser support') + '\n';
+ output += snippet.attributes.browserSupport.supportPercentage.toFixed(1) + '%';
+ output += snippet.attributes.browserSupport.text;
+
+ output +=
+ '\n ' + misc.link('⬆ Back to top', misc.anchor('Contents')) + '\n';
}
- )
- const browserSupportHeading = snippetEl.querySelector('h4:last-of-type')
- browserSupportHeading.after(
- createElement(`
-
-
- ${featUsageShares.length ? Math.min(...featUsageShares).toPrecision(3) : 100}%
-
-
- `)
- )
-
- // sidebar link
- const link = createElement(
- ``
- )
-
- // new icon = less than 31 days old
- const date = (snippetData.match(//) || [, ''])[1]
- if (date && differenceInDays(new Date(), new Date(date)) < 31) {
- const newIcon = ' '
- snippetEl.prepend(createElement(newIcon))
- link.prepend(createElement(newIcon))
}
- // tags
- const tags = (snippetData.match(//) || [, ''])[1]
- .split(/,\s*/)
- .forEach(tag => {
- tag = tag.trim().toLowerCase()
- snippetEl
- .querySelector('h3')
- .append(
- createElement(
- ` ${tag} `
- )
- )
-
- sidebarLinkContainer.querySelector(`section[data-type="${tag}"]`).append(link)
- })
+ // Add the ending static part
+ output += `\n${endPart}\n`;
+ // Write to the README file
+ fs.writeFileSync('README.md', output);
+} catch (err) {
+ console.log(`${red('ERROR!')} During README generation: ${err}`);
+ process.exit(1);
}
-// build dom
-TAGS.forEach(tag =>
- components.tags.append(
- createElement(
- ` ${tag.name} `
- )
- )
-)
-const content = document.querySelector('.content-wrapper')
-content.before(components.backToTopButton)
-content.before(components.sidebar)
-content.append(components.header)
-content.append(components.main)
-components.main.querySelector('.container').prepend(components.tags)
-
-// doctype declaration gets stripped, add it back in
-const html = `
-${pretty(document.documentElement.outerHTML, { ocd: true })}
-`
-
-fs.writeFileSync('./index.html', html)
+console.log(`${green('SUCCESS!')} README file generated!`);
+console.timeEnd('Builder');
diff --git a/scripts/extract.js b/scripts/extract.js
new file mode 100644
index 000000000..73e5fa7b6
--- /dev/null
+++ b/scripts/extract.js
@@ -0,0 +1,80 @@
+/*
+ This is the extractor script that generates the snippets.json file.
+ Run using `npm run extractor`.
+*/
+// Load modules
+const fs = require('fs-extra');
+const path = require('path');
+const { green } = require('kleur');
+const util = require('./util');
+const config = require('../config');
+
+// Paths (relative to package.json)
+const SNIPPETS_PATH = `./${config.snippetPath}`;
+const OUTPUT_PATH = `./${config.snippetDataPath}`;
+
+// Check if running on Travis, only build for cron jobs and custom builds
+if (
+ util.isTravisCI() &&
+ process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
+ process.env['TRAVIS_EVENT_TYPE'] !== 'api'
+) {
+ console.log(
+ `${green(
+ 'NOBUILD',
+ )} snippet extraction terminated, not a cron or api build!`,
+ );
+ process.exit(0);
+}
+
+// Setup everything
+let snippets = {},
+ snippetsArray = [];
+console.time('Extractor');
+
+// Synchronously read all snippets from snippets folder and sort them as necessary (case-insensitive)
+snippets = util.readSnippets(SNIPPETS_PATH);
+snippetsArray = Object.keys(snippets).reduce((acc, key) => {
+ acc.push(snippets[key]);
+ return acc;
+}, []);
+
+const completeData = {
+ data: [...snippetsArray],
+ meta: {
+ specification: 'http://jsonapi.org/format/',
+ type: 'snippetArray',
+ },
+};
+let listingData = {
+ data: completeData.data.map(v => ({
+ id: v.id,
+ type: 'snippetListing',
+ title: v.title,
+ attributes: {
+ text: v.attributes.text,
+ tags: v.attributes.tags,
+ },
+ meta: {
+ hash: v.meta.hash,
+ },
+ })),
+ meta: {
+ specification: 'http://jsonapi.org/format/',
+ type: 'snippetListingArray',
+ },
+};
+// Write files
+fs.writeFileSync(
+ path.join(OUTPUT_PATH, 'snippets.json'),
+ JSON.stringify(completeData, null, 2),
+);
+fs.writeFileSync(
+ path.join(OUTPUT_PATH, 'snippetList.json'),
+ JSON.stringify(listingData, null, 2),
+);
+// Display messages and time
+console.log(
+ `${green('SUCCESS!')} snippets.json and snippetList.json files generated!`,
+);
+console.timeEnd('Extractor');
diff --git a/scripts/util/environmentCheck.js b/scripts/util/environmentCheck.js
new file mode 100644
index 000000000..05c441bb9
--- /dev/null
+++ b/scripts/util/environmentCheck.js
@@ -0,0 +1,12 @@
+// Checks if current environment is Travis CI, Cron builds, API builds
+const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
+const isTravisCronOrAPI = () =>
+ process.env['TRAVIS_EVENT_TYPE'] === 'cron' ||
+ process.env['TRAVIS_EVENT_TYPE'] === 'api';
+const isNotTravisCronOrAPI = () => !isTravisCronOrAPI();
+
+module.exports = {
+ isTravisCI,
+ isTravisCronOrAPI,
+ isNotTravisCronOrAPI,
+};
diff --git a/scripts/util/helpers.js b/scripts/util/helpers.js
new file mode 100644
index 000000000..de1386935
--- /dev/null
+++ b/scripts/util/helpers.js
@@ -0,0 +1,60 @@
+const config = require('../../config');
+
+const getMarkDownAnchor = paragraphTitle =>
+ paragraphTitle
+ .trim()
+ .toLowerCase()
+ .replace(/[^\w\- ]+/g, '')
+ .replace(/\s/g, '-')
+ .replace(/\-+$/, '');
+// Creates an object from pairs
+const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
+// Optimizes nodes in an HTML document
+const optimizeNodes = (data, regexp, replacer) => {
+ let count = 0;
+ let output = data;
+ do {
+ output = output.replace(regexp, replacer);
+ count = 0;
+ while (regexp.exec(output) !== null) ++count;
+ } while (count > 0);
+ return output;
+};
+// Capitalizes the first letter of a string
+const capitalize = (str, lowerRest = false) =>
+ str.slice(0, 1).toUpperCase() +
+ (lowerRest ? str.slice(1).toLowerCase() : str.slice(1));
+const prepTaggedData = tagDbData =>
+ [...new Set(Object.entries(tagDbData).map(t => t[1][0]))]
+ .filter(v => v)
+ .sort((a, b) =>
+ capitalize(a, true) === 'Uncategorized'
+ ? 1
+ : capitalize(b, true) === 'Uncategorized'
+ ? -1
+ : a.localeCompare(b),
+ );
+const makeExamples = data => {
+ data =
+ data.slice(0, data.lastIndexOf(`\`\`\`${config.language}`)).trim() +
+ misc.collapsible(
+ 'Examples',
+ data.slice(
+ data.lastIndexOf(`\`\`\`${config.language}`),
+ data.lastIndexOf('```'),
+ ) + data.slice(data.lastIndexOf('```')),
+ );
+ return `${data}\n ${misc.link(
+ '⬆ Back to top',
+ misc.anchor('Contents'),
+ )}\n\n`;
+};
+
+module.exports = {
+ getMarkDownAnchor,
+ objectFromPairs,
+ optimizeNodes,
+ capitalize,
+ prepTaggedData,
+ makeExamples,
+};
diff --git a/scripts/util/index.js b/scripts/util/index.js
new file mode 100644
index 000000000..27edbfec9
--- /dev/null
+++ b/scripts/util/index.js
@@ -0,0 +1,37 @@
+const {
+ isTravisCI,
+ isTravisCronOrAPI,
+ isNotTravisCronOrAPI,
+} = require('./environmentCheck');
+const {
+ getMarkDownAnchor,
+ objectFromPairs,
+ optimizeNodes,
+ capitalize,
+ prepTaggedData,
+ makeExamples,
+} = require('./helpers');
+const {
+ getFilesInDir,
+ hashData,
+ getCodeBlocks,
+ getTextualContent,
+ readSnippets,
+} = require('./snippetParser');
+
+module.exports = {
+ isTravisCI,
+ isTravisCronOrAPI,
+ isNotTravisCronOrAPI,
+ getMarkDownAnchor,
+ objectFromPairs,
+ optimizeNodes,
+ capitalize,
+ prepTaggedData,
+ makeExamples,
+ getFilesInDir,
+ hashData,
+ getCodeBlocks,
+ getTextualContent,
+ readSnippets,
+};
diff --git a/scripts/util/snippetParser.js b/scripts/util/snippetParser.js
new file mode 100644
index 000000000..b697270ce
--- /dev/null
+++ b/scripts/util/snippetParser.js
@@ -0,0 +1,198 @@
+const fs = require('fs-extra'),
+ path = require('path'),
+ { red } = require('kleur'),
+ crypto = require('crypto'),
+ frontmatter = require('front-matter');
+const sass = require('node-sass');
+const caniuseDb = require('caniuse-db/data.json');
+const config = require('../../config');
+
+// Reade all files in a directory
+const getFilesInDir = (directoryPath, withPath, exclude = null) => {
+ try {
+ let directoryFilenames = fs.readdirSync(directoryPath);
+ directoryFilenames.sort((a, b) => {
+ a = a.toLowerCase();
+ b = b.toLowerCase();
+ if (a < b) return -1;
+ if (a > b) return 1;
+ return 0;
+ });
+
+ if (withPath) {
+ // a hacky way to do conditional array.map
+ return directoryFilenames.reduce((fileNames, fileName) => {
+ if (
+ exclude == null ||
+ !exclude.some(toExclude => fileName === toExclude)
+ )
+ fileNames.push(`${directoryPath}/${fileName}`);
+ return fileNames;
+ }, []);
+ }
+ return directoryFilenames.filter(v => v !== 'README.md');
+ } catch (err) {
+ console.log(`${red('ERROR!')} During snippet loading: ${err}`);
+ process.exit(1);
+ }
+};
+// Creates a hash for a value using the SHA-256 algorithm.
+const hashData = val =>
+ crypto
+ .createHash('sha256')
+ .update(val)
+ .digest('hex');
+// Gets the code blocks for a snippet file.
+const getCodeBlocks = str => {
+ const regex = /```[.\S\s]*?```/g;
+ let results = [];
+ let m = null;
+ while ((m = regex.exec(str)) !== null) {
+ if (m.index === regex.lastIndex) regex.lastIndex += 1;
+
+ m.forEach((match, groupIndex) => {
+ results.push(match);
+ });
+ }
+ const replacer = new RegExp(
+ `\`\`\`${config.language}([\\s\\S]*?)\`\`\``,
+ 'g',
+ );
+ const secondReplacer = new RegExp(
+ `\`\`\`${config.secondLanguage}([\\s\\S]*?)\`\`\``,
+ 'g',
+ );
+ const optionalReplacer = new RegExp(
+ `\`\`\`${config.optionalLanguage}([\\s\\S]*?)\`\`\``,
+ 'g',
+ );
+ results = results.map(v =>
+ v
+ .replace(replacer, '$1')
+ .replace(secondReplacer, '$1')
+ .replace(optionalReplacer, '$1')
+ .trim()
+ );
+ if (results.length > 2)
+ return {
+ html: results[0],
+ css: results[1],
+ js: results[2],
+ };
+ return {
+ html: results[0],
+ css: results[1],
+ js: '',
+ };
+};
+// Gets the textual content for a snippet file.
+const getTextualContent = str => {
+ const regex = /([\s\S]*?)```/g;
+ const results = [];
+ let m = null;
+ while ((m = regex.exec(str)) !== null) {
+ if (m.index === regex.lastIndex) regex.lastIndex += 1;
+
+ m.forEach((match, groupIndex) => {
+ results.push(match);
+ });
+ }
+ return results[1].replace(/\r\n/g, '\n');
+};
+
+// Gets the explanation for a snippet file.
+const getExplanation = str => {
+ const regex = /####\s*Explanation([\s\S]*)####/g;
+ const results = [];
+ let m = null;
+ while ((m = regex.exec(str)) !== null) {
+ if (m.index === regex.lastIndex) regex.lastIndex += 1;
+
+ m.forEach((match, groupIndex) => {
+ results.push(match);
+ });
+ }
+ // console.log(results);
+ return results[1].replace(/\r\n/g, '\n');
+};
+
+// Gets the browser support for a snippet file.
+const getBrowserSupport = str => {
+ const regex = /####\s*Browser [s|S]upport([\s\S]*)/g;
+ const results = [];
+ let m = null;
+ while ((m = regex.exec(str)) !== null) {
+ if (m.index === regex.lastIndex) regex.lastIndex += 1;
+
+ m.forEach((match, groupIndex) => {
+ results.push(match);
+ });
+ }
+ let browserSupportText = results[1].replace(/\r\n/g, '\n');
+ const supportPercentage = (browserSupportText.match(/https?:\/\/caniuse\.com\/#feat=.*/g) || []).map(
+ feat => {
+ const featData = caniuseDb.data[feat.match(/#feat=(.*)/)[1]];
+ // caniuse doesn't count "untracked" users, which makes the overall share appear much lower
+ // than it probably is. Most of these untracked browsers probably support these features.
+ // Currently it's around 5.3% untracked, so we'll use 4% as probably supporting the feature.
+ // Also the npm package appears to be show higher usage % than the main website, this shows
+ // about 0.2% lower than the main website when selecting "tracked users" (as of Feb 2019).
+ const UNTRACKED_PERCENT = 4;
+ const usage = featData
+ ? Number(featData.usage_perc_y + featData.usage_perc_a) + UNTRACKED_PERCENT
+ : 100;
+ return Math.min(100, usage);
+ }
+ )
+ return {
+ text: browserSupportText,
+ supportPercentage: Math.min(...supportPercentage)
+ }
+};
+
+// Synchronously read all snippets and sort them as necessary (case-insensitive)
+const readSnippets = snippetsPath => {
+ const snippetFilenames = getFilesInDir(snippetsPath, false);
+
+ let snippets = {};
+ try {
+ for (let snippet of snippetFilenames) {
+ let data = frontmatter(
+ fs.readFileSync(path.join(snippetsPath, snippet), 'utf8'),
+ );
+ snippets[snippet] = {
+ id: snippet.slice(0, -3),
+ title: data.attributes.title,
+ type: 'snippet',
+ attributes: {
+ fileName: snippet,
+ text: getTextualContent(data.body),
+ explanation: getExplanation(data.body),
+ browserSupport: getBrowserSupport(data.body),
+ codeBlocks: getCodeBlocks(data.body),
+ tags: data.attributes.tags.split(',').map(t => t.trim()),
+ },
+ meta: {
+ hash: hashData(data.body),
+ },
+ };
+ snippets[snippet].attributes.codeBlocks.scopedCss = sass.renderSync({
+ data: `[data-scope="${snippets[snippet].id}"] { ${snippets[snippet].attributes.codeBlocks.css} }`
+ }).css.toString();
+ }
+ } catch (err) {
+ console.log(`${red('ERROR!')} During snippet loading: ${err}`);
+ process.exit(1);
+ }
+ return snippets;
+};
+
+module.exports = {
+ getFilesInDir,
+ hashData,
+ getCodeBlocks,
+ getTextualContent,
+ getExplanation,
+ getBrowserSupport,
+ readSnippets,
+};
diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json
new file mode 100644
index 000000000..47b7a08ea
--- /dev/null
+++ b/snippet_data/snippetList.json
@@ -0,0 +1,704 @@
+{
+ "data": [
+ {
+ "id": "bouncing-loader",
+ "type": "snippetListing",
+ "title": "Bouncing loader",
+ "attributes": {
+ "text": "Creates a bouncing loader animation.\n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "5093345481ba16eb2d9b547cc55a2ac1993c39ffe09a4c40255c9e4d9cae4cc7"
+ }
+ },
+ {
+ "id": "box-sizing-reset",
+ "type": "snippetListing",
+ "title": "Box-sizing reset",
+ "attributes": {
+ "text": "Resets the box-model so that `width`s and `height`s are not affected by their `border`s or `padding`.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "a67133bc7bf6d831340501643c7efede36b09a7f36516e0cc7fb7d3ff06ee7bd"
+ }
+ },
+ {
+ "id": "button-border-animation",
+ "type": "snippetListing",
+ "title": "Button border animation",
+ "attributes": {
+ "text": "Creates a border animation on hover.\n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "754e9dc4b820bbd2f8650a06df9cf2d2e3755b0da2ae2be787bf77eb79d0e296"
+ }
+ },
+ {
+ "id": "calc",
+ "type": "snippetListing",
+ "title": "Calc()",
+ "attributes": {
+ "text": "The function calc() allows to define CSS values with the use of mathematical expressions, the value adopted for the property is the result of a mathematical expression.\n\n\n\n",
+ "tags": [
+ "other",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "fce405ede3127f068a4598d709484dae8b3991594daf5d54fbac043989d04427"
+ }
+ },
+ {
+ "id": "circle",
+ "type": "snippetListing",
+ "title": "Circle",
+ "attributes": {
+ "text": "Creates a circle shape with pure CSS.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "bc4bbf2fdc171fc581c72926d8b383391c1f01ccdb8853a3b4a1a290fddc704e"
+ }
+ },
+ {
+ "id": "clearfix",
+ "type": "snippetListing",
+ "title": "Clearfix",
+ "attributes": {
+ "text": "Ensures that an element self-clears its children.\n\n###### Note: This is only useful if you are still using float to build layouts. Please consider using a modern approach with flexbox layout or grid layout.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "1047b62d1a05d21a0d5cd370eca23ca76dc52454b1aefdb4bddd83d78a624458"
+ }
+ },
+ {
+ "id": "constant-width-to-height-ratio",
+ "type": "snippetListing",
+ "title": "Constant width to height ratio",
+ "attributes": {
+ "text": "Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion\n(i.e., its width to height ratio remains constant).\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "6d9a462223d6c4d2cb83b0b3ffea991d18d5b4c2bf81881515ff07a7c49db1c8"
+ }
+ },
+ {
+ "id": "counter",
+ "type": "snippetListing",
+ "title": "Counter",
+ "attributes": {
+ "text": "Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.\n\n",
+ "tags": [
+ "visual",
+ "other",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "99ba7570de689df640c22feb4a36874d4d7bc4bd1310227cedabe55d95b83f5e"
+ }
+ },
+ {
+ "id": "custom-scrollbar",
+ "type": "snippetListing",
+ "title": "Custom scrollbar",
+ "attributes": {
+ "text": "Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms.\n\n\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "cd46a337bd537c752499182a18575a921f300cf73b490dea2c1378360e670168"
+ }
+ },
+ {
+ "id": "custom-text-selection",
+ "type": "snippetListing",
+ "title": "Custom text selection",
+ "attributes": {
+ "text": "Changes the styling of text selection.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "fa278f7299768bd484a01a9d63c7e8ba684f3870da53388aae5290d5b4dee7bb"
+ }
+ },
+ {
+ "id": "custom-variables",
+ "type": "snippetListing",
+ "title": "Custom variables",
+ "attributes": {
+ "text": "CSS variables that contain specific values to be reused throughout a document.\n\n",
+ "tags": [
+ "other",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "c03b24d37e43d056aa2e5f6eebb8d61a86d4d9f6587270aa8606df771c27f3cc"
+ }
+ },
+ {
+ "id": "disable-selection",
+ "type": "snippetListing",
+ "title": "Disable selection",
+ "attributes": {
+ "text": "Makes the content unselectable.\n\n",
+ "tags": [
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "ccae3478e0de1ff02bab055c17e2f877bd39cd4994f6b18d0bf85d16e9912dda"
+ }
+ },
+ {
+ "id": "display-table-centering",
+ "type": "snippetListing",
+ "title": "Display table centering",
+ "attributes": {
+ "text": "Vertically and horizontally centers a child element within its parent element using `display: table` (as an alternative to `flexbox`).\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "4b2e48224b08521eda138be98210a643ff98733fed8f9dd9d1921a1f56084450"
+ }
+ },
+ {
+ "id": "donut-spinner",
+ "type": "snippetListing",
+ "title": "Donut spinner",
+ "attributes": {
+ "text": "Creates a donut spinner that can be used to indicate the loading of content.\n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "cf2af5a585eecb3c98ee07d02d2e94ebee5efdf01523313b61faa199309bee0d"
+ }
+ },
+ {
+ "id": "dynamic-shadow",
+ "type": "snippetListing",
+ "title": "Dynamic shadow",
+ "attributes": {
+ "text": "Creates a shadow similar to `box-shadow` but based on the colors of the element itself.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "125c57e66fac5a5f0f231889d6cc2bbab0c8693070254386140468ec39045556"
+ }
+ },
+ {
+ "id": "easing-variables",
+ "type": "snippetListing",
+ "title": "Easing variables",
+ "attributes": {
+ "text": "Variables that can be reused for `transition-timing-function` properties, more\npowerful than the built-in `ease`, `ease-in`, `ease-out` and `ease-in-out`.\n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "742eec324f2b9eb3a5cf972639069523e1244ee95bc6335192587b8f9352f2da"
+ }
+ },
+ {
+ "id": "etched-text",
+ "type": "snippetListing",
+ "title": "Etched text",
+ "attributes": {
+ "text": "Creates an effect where text appears to be \"etched\" or engraved into the background.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "fade4c04ebb8c2e6d680cc803d54738dbb166b6f608f13a94eacfe0b762fb0c4"
+ }
+ },
+ {
+ "id": "evenly-distributed-children",
+ "type": "snippetListing",
+ "title": "Evenly distributed children",
+ "attributes": {
+ "text": "Evenly distributes child elements within a parent element.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "3489ccfed45a24c536c275e7a74cc8727fd801baae9c2b5123265bcd75e70a37"
+ }
+ },
+ {
+ "id": "fit-image-in-container",
+ "type": "snippetListing",
+ "title": "Fit image in container",
+ "attributes": {
+ "text": "Changes the fit and position of an image within its container while preserving its aspect ratio. Previously only possible using a background image and the `background-size` property.\n\n",
+ "tags": [
+ "layout",
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "79cb705dc7ae6fbde94fac8dc3b273dda73be7a4739a2cdf9f160ad6f678133a"
+ }
+ },
+ {
+ "id": "flexbox-centering",
+ "type": "snippetListing",
+ "title": "Flexbox centering",
+ "attributes": {
+ "text": "Horizontally and vertically centers a child element within a parent element using `flexbox`.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "ec62036188c484a98e832c45535eafbf528020f116a5aac0c853b56f6b91162e"
+ }
+ },
+ {
+ "id": "focus-within",
+ "type": "snippetListing",
+ "title": "Focus Within",
+ "attributes": {
+ "text": "Changes the appearance of a form if any of its children are focused.\n\n",
+ "tags": [
+ "visual",
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "db08a880101d0e82dd0263582e7b251d88450df278e7d79a0a544d1575580c55"
+ }
+ },
+ {
+ "id": "fullscreen",
+ "type": "snippetListing",
+ "title": "Fullscreen",
+ "attributes": {
+ "text": "The :fullscreen CSS pseudo-class represents an element that's displayed when the browser is in fullscreen mode.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "2bb108851d15d46749ba4f1caa2ba08d4754a2ee988e812280925c637f610d40"
+ }
+ },
+ {
+ "id": "ghost-trick",
+ "type": "snippetListing",
+ "title": "Ghost trick",
+ "attributes": {
+ "text": "Vertically centers an element in another.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "622cd2ec51c26b37be3ea38a55d71bbb1b5944f14188b484c4903e23b45086c9"
+ }
+ },
+ {
+ "id": "gradient-text",
+ "type": "snippetListing",
+ "title": "Gradient text",
+ "attributes": {
+ "text": "Gives text a gradient color.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "56a606934b50e0c3c53eb4819ee3fcb57344a9bd7dce91ae26c6f98c99a4c386"
+ }
+ },
+ {
+ "id": "grid-centering",
+ "type": "snippetListing",
+ "title": "Grid centering",
+ "attributes": {
+ "text": "Horizontally and vertically centers a child element within a parent element using `grid`.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "167267471e09e52f20ed40ffb23b8efa1cfba6434fea5b7c82810c62c8ba5ee0"
+ }
+ },
+ {
+ "id": "hairline-border",
+ "type": "snippetListing",
+ "title": "Hairline border",
+ "attributes": {
+ "text": "Gives an element a border equal to 1 native device pixel in width, which can look\nvery sharp and crisp.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "0e45709255d9ca14598c5fa54c2ae5490f81a0ef67c466d6d678da584340428b"
+ }
+ },
+ {
+ "id": "height-transition",
+ "type": "snippetListing",
+ "title": "Height transition",
+ "attributes": {
+ "text": "Transitions an element's height from `0` to `auto` when its height is unknown.\n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "7ee6c8c6027ccbba77e7c02bdb79cf22a0d22d7acece1ea5408da19a7f986d7a"
+ }
+ },
+ {
+ "id": "hover-shadow-box-animation",
+ "type": "snippetListing",
+ "title": "Hover shadow box animation",
+ "attributes": {
+ "text": "Creates a shadow box around the text when it is hovered.\n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "8fc3c2c5fc4248b2ec6bfdbc96cb5912936ccd5865d88da7a3a041a32168968a"
+ }
+ },
+ {
+ "id": "hover-underline-animation",
+ "type": "snippetListing",
+ "title": "Hover underline animation",
+ "attributes": {
+ "text": "Creates an animated underline effect when the text is hovered over.\n\n**Credit:** https://flatuicolors.com/ \n\n",
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "5ee579737769cd734df27df60b3c0fa296965192f1cdca45d4c43a414c6b9760"
+ }
+ },
+ {
+ "id": "last-item-with-remaining-available-height",
+ "type": "snippetListing",
+ "title": "Last item with remaining available height",
+ "attributes": {
+ "text": "Take advantage of available viewport space by giving the last element the remaining available space in current viewport, even when resizing the window.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "522a5e309cea7f772600ca1d5f89ee911f0aec94b157e2adb94ac3f479445c01"
+ }
+ },
+ {
+ "id": "mouse-cursor-gradient-tracking",
+ "type": "snippetListing",
+ "title": "Mouse cursor gradient tracking",
+ "attributes": {
+ "text": "A hover effect where the gradient follows the mouse cursor.\n\n**Credit:** [Tobias Reich](https://codepen.io/electerious/pen/MQrRxX) \n\n",
+ "tags": [
+ "visual",
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "707e50fd348545fc1f9950ef9cda9e74b28ffe57098cc2849c72358c4bf7bea6"
+ }
+ },
+ {
+ "id": "not-selector",
+ "type": "snippetListing",
+ "title": ":not selector",
+ "attributes": {
+ "text": "The `:not` psuedo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "7d2727a78b8ee2a55a823116fb01099efa227952d8fba8c35a1d3067675985d5"
+ }
+ },
+ {
+ "id": "offscreen",
+ "type": "snippetListing",
+ "title": "Offscreen",
+ "attributes": {
+ "text": "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.\n\n",
+ "tags": [
+ "layout",
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "000a1fd47f9dafba64a625aefc689e33592adf69c8c5ecffb6de68a83f0218aa"
+ }
+ },
+ {
+ "id": "overflow-scroll-gradient",
+ "type": "snippetListing",
+ "title": "Overflow scroll gradient",
+ "attributes": {
+ "text": "Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "6ce90f10b574780c196faad6a498c8d5b1e5e2d6c3464ded47ceb1056b24baa3"
+ }
+ },
+ {
+ "id": "popout-menu",
+ "type": "snippetListing",
+ "title": "Popout menu",
+ "attributes": {
+ "text": "Reveals an interactive popout menu on hover and focus.\n\n",
+ "tags": [
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "8f5c19fb14ee8039e93ff0f3185cb0d27971dd2509f6100fdfd290478211a42b"
+ }
+ },
+ {
+ "id": "pretty-text-underline",
+ "type": "snippetListing",
+ "title": "Pretty text underline",
+ "attributes": {
+ "text": "A nicer alternative to `text-decoration: underline` or ` ` where descenders do not clip the underline.\nNatively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "5d0eb22cb50d397c88c5f3a111a6a85d6cfa7d61fb7e88c966fdd55fe9d5b587"
+ }
+ },
+ {
+ "id": "reset-all-styles",
+ "type": "snippetListing",
+ "title": "Reset all styles",
+ "attributes": {
+ "text": "Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "d601816311504b7521c8bba212e2c4b6fb50317ec10df60991a414bae1c82bf9"
+ }
+ },
+ {
+ "id": "shape-separator",
+ "type": "snippetListing",
+ "title": "Shape separator",
+ "attributes": {
+ "text": "Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "1ce90fc518399c775df1af832345729bdde2a3c12bbdd2fd66c40b9c57a65aa1"
+ }
+ },
+ {
+ "id": "sibling-fade",
+ "type": "snippetListing",
+ "title": "Sibling fade",
+ "attributes": {
+ "text": "Fades out the siblings of a hovered item.\n\n",
+ "tags": [
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "a1e353f0dc466a24881986bbaf8f2cd9f367fe80d54ac8e1481d82e021236389"
+ }
+ },
+ {
+ "id": "system-font-stack",
+ "type": "snippetListing",
+ "title": "System font stack",
+ "attributes": {
+ "text": "Uses the native font of the operating system to get close to a native app feel.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "0a35134bd1fe1da354810ef3228f50a81105997c0e81138c97cc9ace399adbb2"
+ }
+ },
+ {
+ "id": "toggle-switch",
+ "type": "snippetListing",
+ "title": "Toggle switch",
+ "attributes": {
+ "text": "Creates a toggle switch with CSS only.\n\n",
+ "tags": [
+ "visual",
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "6af55186736cae8da52a2a92bf7dcf56f6f23ca49ce083ad6653e373fa2d152e"
+ }
+ },
+ {
+ "id": "transform-centering",
+ "type": "snippetListing",
+ "title": "Transform centering",
+ "attributes": {
+ "text": "Vertically and horizontally centers a child element within its parent element using `position: absolute` and `transform: translate()` (as an alternative to `flexbox` or `display: table`). Similar to `flexbox`, this method does not require you to know the height or width of your parent or child so it is ideal for responsive applications.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "67b5f73d1e7aa4850b39c461fd93a548e106569554cf6e87f2a9981ecfb77ad1"
+ }
+ },
+ {
+ "id": "triangle",
+ "type": "snippetListing",
+ "title": "Triangle",
+ "attributes": {
+ "text": "Creates a triangle shape with pure CSS.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "d585e568bd1b8ca9c8a7d2fa52682c80249bf1e6055316bc3526ee54d8d26fb9"
+ }
+ },
+ {
+ "id": "truncate-text-multiline",
+ "type": "snippetListing",
+ "title": "Truncate text multiline",
+ "attributes": {
+ "text": "If the text is longer than one line, it will be truncated for `n` lines and end with an gradient fade.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "487720c3bf69c29c26cd0033d69f7391b634c4d9bf0e72a1da29957b945a9cbf"
+ }
+ },
+ {
+ "id": "truncate-text",
+ "type": "snippetListing",
+ "title": "Truncate text",
+ "attributes": {
+ "text": "If the text is longer than one line, it will be truncated and end with an ellipsis `…`.\n\n",
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "db78085f4583d992126b4ceb74cc680300aa67c16d37b68d55c140fe453840d3"
+ }
+ },
+ {
+ "id": "zebra-striped-list",
+ "type": "snippetListing",
+ "title": "Zebra striped list",
+ "attributes": {
+ "text": "Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row.\n\n",
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "2c11f668918ede13c492719a76a5b89173aa4e72ad896cd2d7e45bed9671a2f0"
+ }
+ }
+ ],
+ "meta": {
+ "specification": "http://jsonapi.org/format/",
+ "type": "snippetListingArray"
+ }
+}
\ No newline at end of file
diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json
new file mode 100644
index 000000000..9ba58cf96
--- /dev/null
+++ b/snippet_data/snippets.json
@@ -0,0 +1,1256 @@
+{
+ "data": [
+ {
+ "id": "bouncing-loader",
+ "title": "Bouncing loader",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "bouncing-loader.md",
+ "text": "Creates a bouncing loader animation.\n\n",
+ "explanation": "\n\nNote: `1rem` is usually `16px`.\n\n1. `@keyframes` defines an animation that has two states, where the element changes `opacity` and is translated up on the 2D plane using `transform: translate3d()`. Using a single axis translation on `transform: translate3d()` improves the performance of the animation.\n\n2. `.bouncing-loader` is the parent container of the bouncing circles and uses `display: flex`\n and `justify-content: center` to position them in the center.\n\n3. `.bouncing-loader > div`, targets the three child `div`s of the parent to be styled. The `div`s are given a width and height of `1rem`, using `border-radius: 50%` to turn them from squares to circles.\n\n4. `margin: 3rem 0.2rem` specifies that each circle has a top/bottom margin of `3rem` and left/right margin\n of `0.2rem` so that they do not directly touch each other, giving them some breathing room.\n\n5. `animation` is a shorthand property for the various animation properties: `animation-name`, `animation-duration`, `animation-iteration-count`, `animation-direction` are used.\n\n6. `nth-child(n)` targets the element which is the nth child of its parent.\n\n7. `animation-delay` is used on the second and third `div` respectively, so that each element does not start the animation at the same time.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-animation\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "",
+ "css": "@keyframes bouncing-loader {\r\n to {\r\n opacity: 0.1;\r\n transform: translate3d(0, -1rem, 0);\r\n }\r\n}\r\n.bouncing-loader {\r\n display: flex;\r\n justify-content: center;\r\n}\r\n.bouncing-loader > div {\r\n width: 1rem;\r\n height: 1rem;\r\n margin: 3rem 0.2rem;\r\n background: #8385aa;\r\n border-radius: 50%;\r\n animation: bouncing-loader 0.6s infinite alternate;\r\n}\r\n.bouncing-loader > div:nth-child(2) {\r\n animation-delay: 0.2s;\r\n}\r\n.bouncing-loader > div:nth-child(3) {\r\n animation-delay: 0.4s;\r\n}",
+ "js": "",
+ "scopedCss": "@keyframes bouncing-loader {\n to {\n opacity: 0.1;\n transform: translate3d(0, -1rem, 0); } }\n\n[data-scope=\"bouncing-loader\"] .bouncing-loader {\n display: flex;\n justify-content: center; }\n\n[data-scope=\"bouncing-loader\"] .bouncing-loader > div {\n width: 1rem;\n height: 1rem;\n margin: 3rem 0.2rem;\n background: #8385aa;\n border-radius: 50%;\n animation: bouncing-loader 0.6s infinite alternate; }\n\n[data-scope=\"bouncing-loader\"] .bouncing-loader > div:nth-child(2) {\n animation-delay: 0.2s; }\n\n[data-scope=\"bouncing-loader\"] .bouncing-loader > div:nth-child(3) {\n animation-delay: 0.4s; }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "5093345481ba16eb2d9b547cc55a2ac1993c39ffe09a4c40255c9e4d9cae4cc7"
+ }
+ },
+ {
+ "id": "box-sizing-reset",
+ "title": "Box-sizing reset",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "box-sizing-reset.md",
+ "text": "Resets the box-model so that `width`s and `height`s are not affected by their `border`s or `padding`.\n\n",
+ "explanation": "\n\n1. `box-sizing: border-box` makes the addition of `padding` or `border`s not affect an element's `width` or `height`.\n2. `box-sizing: inherit` makes an element respect its parent's `box-sizing` rule.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css3-boxsizing\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "border-box
\r\ncontent-box
",
+ "css": "html {\r\n box-sizing: border-box;\r\n}\r\n*,\r\n*::before,\r\n*::after {\r\n box-sizing: inherit;\r\n}\r\n.box {\r\n display: inline-block;\r\n width: 150px;\r\n height: 150px;\r\n padding: 10px;\r\n background: tomato;\r\n color: white;\r\n border: 10px solid red;\r\n}\r\n.content-box {\r\n box-sizing: content-box;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"box-sizing-reset\"] html {\n box-sizing: border-box; }\n\n[data-scope=\"box-sizing-reset\"] *,\n[data-scope=\"box-sizing-reset\"] *::before,\n[data-scope=\"box-sizing-reset\"] *::after {\n box-sizing: inherit; }\n\n[data-scope=\"box-sizing-reset\"] .box {\n display: inline-block;\n width: 150px;\n height: 150px;\n padding: 10px;\n background: tomato;\n color: white;\n border: 10px solid red; }\n\n[data-scope=\"box-sizing-reset\"] .content-box {\n box-sizing: content-box; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "a67133bc7bf6d831340501643c7efede36b09a7f36516e0cc7fb7d3ff06ee7bd"
+ }
+ },
+ {
+ "id": "button-border-animation",
+ "title": "Button border animation",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "button-border-animation.md",
+ "text": "Creates a border animation on hover.\n\n",
+ "explanation": "\n\nUse the `:before` and `:after` pseduo-elements as borders that animate on hover.\n\n",
+ "browserSupport": {
+ "text": "\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "Submit
",
+ "css": ".button {\r\n background-color: #c47135;\r\n border: none;\r\n color: #ffffff;\r\n outline: none;\r\n padding: 12px 40px 10px;\r\n position: relative;\r\n}\r\n.button:before,\r\n.button:after {\r\n border: 0 solid transparent;\r\n transition: all 0.25s;\r\n content: '';\r\n height: 24px;\r\n position: absolute;\r\n width: 24px;\r\n}\r\n.button:before {\r\n border-top: 2px solid #c47135;\r\n left: 0px;\r\n top: -5px;\r\n}\r\n.button:after {\r\n border-bottom: 2px solid #c47135;\r\n bottom: -5px;\r\n right: 0px;\r\n}\r\n.button:hover {\r\n background-color: #c47135;\r\n}\r\n.button:hover:before,\r\n.button:hover:after {\r\n height: 100%;\r\n width: 100%;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"button-border-animation\"] .button {\n background-color: #c47135;\n border: none;\n color: #ffffff;\n outline: none;\n padding: 12px 40px 10px;\n position: relative; }\n\n[data-scope=\"button-border-animation\"] .button:before,\n[data-scope=\"button-border-animation\"] .button:after {\n border: 0 solid transparent;\n transition: all 0.25s;\n content: '';\n height: 24px;\n position: absolute;\n width: 24px; }\n\n[data-scope=\"button-border-animation\"] .button:before {\n border-top: 2px solid #c47135;\n left: 0px;\n top: -5px; }\n\n[data-scope=\"button-border-animation\"] .button:after {\n border-bottom: 2px solid #c47135;\n bottom: -5px;\n right: 0px; }\n\n[data-scope=\"button-border-animation\"] .button:hover {\n background-color: #c47135; }\n\n[data-scope=\"button-border-animation\"] .button:hover:before,\n[data-scope=\"button-border-animation\"] .button:hover:after {\n height: 100%;\n width: 100%; }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "754e9dc4b820bbd2f8650a06df9cf2d2e3755b0da2ae2be787bf77eb79d0e296"
+ }
+ },
+ {
+ "id": "calc",
+ "title": "Calc()",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "calc.md",
+ "text": "The function calc() allows to define CSS values with the use of mathematical expressions, the value adopted for the property is the result of a mathematical expression.\n\n\n\n",
+ "explanation": "\n\n1. It allows addition, subtraction, multiplication and division.\n2. Can use different units (pixel and percent together, for example) for each value in your expression.\n3. It is permitted to nest calc() functions.\n4. It can be used in any property that ``, ``, ``, ``, ``, ``, or `` is allowed, like width, height, font-size, top, left, etc.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=calc\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".box-example {\r\n height: 280px;\r\n background: #222 url('https://image.ibb.co/fUL9nS/wolf.png') no-repeat;\r\n background-position: calc(100% - 20px) calc(100% - 20px);\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"calc\"] .box-example {\n height: 280px;\n background: #222 url(\"https://image.ibb.co/fUL9nS/wolf.png\") no-repeat;\n background-position: calc(100% - 20px) calc(100% - 20px); }\n"
+ },
+ "tags": [
+ "other",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "fce405ede3127f068a4598d709484dae8b3991594daf5d54fbac043989d04427"
+ }
+ },
+ {
+ "id": "circle",
+ "title": "Circle",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "circle.md",
+ "text": "Creates a circle shape with pure CSS.\n\n",
+ "explanation": "\n\n`border-radius: 50%` curves the borders of an element to create a circle.\n\nSince a circle has the same radius at any given point, the `width` and `height` must be the same. Differing\nvalues will create an ellipse.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=border-radius\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".circle {\r\n border-radius: 50%;\r\n width: 2rem;\r\n height: 2rem;\r\n background: #333;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"circle\"] .circle {\n border-radius: 50%;\n width: 2rem;\n height: 2rem;\n background: #333; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "bc4bbf2fdc171fc581c72926d8b383391c1f01ccdb8853a3b4a1a290fddc704e"
+ }
+ },
+ {
+ "id": "clearfix",
+ "title": "Clearfix",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "clearfix.md",
+ "text": "Ensures that an element self-clears its children.\n\n###### Note: This is only useful if you are still using float to build layouts. Please consider using a modern approach with flexbox layout or grid layout.\n\n",
+ "explanation": "\n\n1. `.clearfix::after` defines a pseudo-element.\n2. `content: ''` allows the pseudo-element to affect layout.\n3. `clear: both` indicates that the left, right or both sides of the element cannot be adjacent\n to earlier floated elements within the same block formatting context.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ For this snippet to work properly you need to ensure that there are no non-floating children in the container and that there are no tall floats before the clearfixed container but in the same formatting context (e.g. floated columns). \n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "\r\n
float a
\r\n
float b
\r\n
float c
\r\n
",
+ "css": ".clearfix::after {\r\n content: '';\r\n display: block;\r\n clear: both;\r\n}\r\n\r\n.floated {\r\n float: left;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"clearfix\"] .clearfix::after {\n content: '';\n display: block;\n clear: both; }\n\n[data-scope=\"clearfix\"] .floated {\n float: left; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "1047b62d1a05d21a0d5cd370eca23ca76dc52454b1aefdb4bddd83d78a624458"
+ }
+ },
+ {
+ "id": "constant-width-to-height-ratio",
+ "title": "Constant width to height ratio",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "constant-width-to-height-ratio.md",
+ "text": "Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion\n(i.e., its width to height ratio remains constant).\n\n",
+ "explanation": "\n\n`padding-top` on the `::before` pseudo-element causes the height of the element to equal a percentage of\nits width. `100%` therefore means the element's height will always be `100%` of the width, creating a responsive\nsquare.\n\nThis method also allows content to be placed inside the element normally.\n\n",
+ "browserSupport": {
+ "text": "\n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".constant-width-to-height-ratio {\r\n background: #333;\r\n width: 50%;\r\n}\r\n.constant-width-to-height-ratio::before {\r\n content: '';\r\n padding-top: 100%;\r\n float: left;\r\n}\r\n.constant-width-to-height-ratio::after {\r\n content: '';\r\n display: block;\r\n clear: both;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"constant-width-to-height-ratio\"] .constant-width-to-height-ratio {\n background: #333;\n width: 50%; }\n\n[data-scope=\"constant-width-to-height-ratio\"] .constant-width-to-height-ratio::before {\n content: '';\n padding-top: 100%;\n float: left; }\n\n[data-scope=\"constant-width-to-height-ratio\"] .constant-width-to-height-ratio::after {\n content: '';\n display: block;\n clear: both; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "6d9a462223d6c4d2cb83b0b3ffea991d18d5b4c2bf81881515ff07a7c49db1c8"
+ }
+ },
+ {
+ "id": "counter",
+ "title": "Counter",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "counter.md",
+ "text": "Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.\n\n",
+ "explanation": "\n\nYou can create a ordered list using any type of HTML.\n\n1. `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.\n\n2. `counter-increment` Used in element that will be countable. Once `counter-reset` initialized, a counter's value can be increased or decreased.\n\n3. `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).\n\n4. `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).\n\n5. 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.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-counters\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n List item \r\n List item \r\n \r\n List item\r\n \r\n List item \r\n List item \r\n List item \r\n \r\n \r\n ",
+ "css": "ul {\r\n counter-reset: counter;\r\n}\r\n\r\nli::before {\r\n counter-increment: counter;\r\n content: counters(counter, '.') ' ';\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"counter\"] ul {\n counter-reset: counter; }\n\n[data-scope=\"counter\"] li::before {\n counter-increment: counter;\n content: counters(counter, \".\") \" \"; }\n"
+ },
+ "tags": [
+ "visual",
+ "other",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "99ba7570de689df640c22feb4a36874d4d7bc4bd1310227cedabe55d95b83f5e"
+ }
+ },
+ {
+ "id": "custom-scrollbar",
+ "title": "Custom scrollbar",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "custom-scrollbar.md",
+ "text": "Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms.\n\n\n\n",
+ "explanation": "\n\n1. `::-webkit-scrollbar` targets the whole scrollbar element.\n2. `::-webkit-scrollbar-track` targets only the scrollbar track.\n3. `::-webkit-scrollbar-thumb` targets the scrollbar thumb.\n\nThere are many other pseudo-elements that you can use to style scrollbars. For more info, visit the [WebKit Blog](https://webkit.org/blog/363/styling-scrollbars/).\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Scrollbar styling doesn't appear to be on any standards track. \n\n- https://caniuse.com/#feat=css-scrollbar\n\n\n\n",
+ "supportPercentage": 97.69
+ },
+ "codeBlocks": {
+ "html": "",
+ "css": ".custom-scrollbar {\r\n height: 70px;\r\n overflow-y: scroll;\r\n}\r\n\r\n/* To style the document scrollbar, remove `.custom-scrollbar` */\r\n\r\n.custom-scrollbar::-webkit-scrollbar {\r\n width: 8px;\r\n}\r\n\r\n.custom-scrollbar::-webkit-scrollbar-track {\r\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);\r\n border-radius: 10px;\r\n}\r\n\r\n.custom-scrollbar::-webkit-scrollbar-thumb {\r\n border-radius: 10px;\r\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"custom-scrollbar\"] {\n /* To style the document scrollbar, remove `.custom-scrollbar` */ }\n [data-scope=\"custom-scrollbar\"] .custom-scrollbar {\n height: 70px;\n overflow-y: scroll; }\n [data-scope=\"custom-scrollbar\"] .custom-scrollbar::-webkit-scrollbar {\n width: 8px; }\n [data-scope=\"custom-scrollbar\"] .custom-scrollbar::-webkit-scrollbar-track {\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);\n border-radius: 10px; }\n [data-scope=\"custom-scrollbar\"] .custom-scrollbar::-webkit-scrollbar-thumb {\n border-radius: 10px;\n box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5); }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "cd46a337bd537c752499182a18575a921f300cf73b490dea2c1378360e670168"
+ }
+ },
+ {
+ "id": "custom-text-selection",
+ "title": "Custom text selection",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "custom-text-selection.md",
+ "text": "Changes the styling of text selection.\n\n",
+ "explanation": "\n\n`::selection` defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Requires prefixes for full support and is not actually\nin any specification. \n\n- https://caniuse.com/#feat=css-selection\n\n\n\n",
+ "supportPercentage": 90.1
+ },
+ "codeBlocks": {
+ "html": "Select some of this text.
",
+ "css": "::selection {\r\n background: aquamarine;\r\n color: black;\r\n}\r\n.custom-text-selection::selection {\r\n background: deeppink;\r\n color: white;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"custom-text-selection\"] ::selection {\n background: aquamarine;\n color: black; }\n\n[data-scope=\"custom-text-selection\"] .custom-text-selection::selection {\n background: deeppink;\n color: white; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "fa278f7299768bd484a01a9d63c7e8ba684f3870da53388aae5290d5b4dee7bb"
+ }
+ },
+ {
+ "id": "custom-variables",
+ "title": "Custom variables",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "custom-variables.md",
+ "text": "CSS variables that contain specific values to be reused throughout a document.\n\n",
+ "explanation": "\n\nThe variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document. Variables can also be scoped to a selector if defined within the block.\n\nDeclare a variable with `--variable-name:`.\n\nReuse variables throughout the document using the `var(--variable-name)` function.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-variables\n\n\n\n",
+ "supportPercentage": 96.51
+ },
+ "codeBlocks": {
+ "html": "CSS is awesome!
",
+ "css": ":root {\r\n /* Place variables within here to use the variables globally. */\r\n}\r\n\r\n.custom-variables {\r\n --some-color: #da7800;\r\n --some-keyword: italic;\r\n --some-size: 1.25em;\r\n --some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray, 0 0 0.2em slategray;\r\n color: var(--some-color);\r\n font-size: var(--some-size);\r\n font-style: var(--some-keyword);\r\n text-shadow: var(--some-complex-value);\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"custom-variables\"] :root {\n /* Place variables within here to use the variables globally. */ }\n\n[data-scope=\"custom-variables\"] .custom-variables {\n --some-color: #da7800;\n --some-keyword: italic;\n --some-size: 1.25em;\n --some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray, 0 0 0.2em slategray;\n color: var(--some-color);\n font-size: var(--some-size);\n font-style: var(--some-keyword);\n text-shadow: var(--some-complex-value); }\n"
+ },
+ "tags": [
+ "other",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "c03b24d37e43d056aa2e5f6eebb8d61a86d4d9f6587270aa8606df771c27f3cc"
+ }
+ },
+ {
+ "id": "disable-selection",
+ "title": "Disable selection",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "disable-selection.md",
+ "text": "Makes the content unselectable.\n\n",
+ "explanation": "\n\n`user-select: none` specifies that the text cannot be selected.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Requires prefixes for full support. \n \n⚠️ This is not a secure method to prevent users from copying content. \n\n- https://caniuse.com/#feat=user-select-none\n\n\n\n",
+ "supportPercentage": 97.51
+ },
+ "codeBlocks": {
+ "html": "You can select me.
\r\nYou can't select me!
",
+ "css": ".unselectable {\r\n user-select: none;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"disable-selection\"] .unselectable {\n user-select: none; }\n"
+ },
+ "tags": [
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "ccae3478e0de1ff02bab055c17e2f877bd39cd4994f6b18d0bf85d16e9912dda"
+ }
+ },
+ {
+ "id": "display-table-centering",
+ "title": "Display table centering",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "display-table-centering.md",
+ "text": "Vertically and horizontally centers a child element within its parent element using `display: table` (as an alternative to `flexbox`).\n\n",
+ "explanation": "\n\n1. `display: table` on '.center' allows the element to behave like a `` HTML element.\n2. 100% height and width on '.center' allows the element to fill the available space within its parent element.\n3. `display: table-cell` on '.center > span' allows the element to behave like an HTML element.\n4. `text-align: center` on '.center > span' centers the child element horizontally.\n5. `vertical-align: middle` on '.center > span' centers the child element vertically.\n\nThe outer parent ('.container' in this case) must have a fixed height and width.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#search=display%3A%20table\n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "\r\n
Centered content
\r\n
",
+ "css": ".container {\r\n border: 1px solid #333;\r\n height: 250px;\r\n width: 250px;\r\n}\r\n\r\n.center {\r\n display: table;\r\n height: 100%;\r\n width: 100%;\r\n}\r\n\r\n.center > span {\r\n display: table-cell;\r\n text-align: center;\r\n vertical-align: middle;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"display-table-centering\"] .container {\n border: 1px solid #333;\n height: 250px;\n width: 250px; }\n\n[data-scope=\"display-table-centering\"] .center {\n display: table;\n height: 100%;\n width: 100%; }\n\n[data-scope=\"display-table-centering\"] .center > span {\n display: table-cell;\n text-align: center;\n vertical-align: middle; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "4b2e48224b08521eda138be98210a643ff98733fed8f9dd9d1921a1f56084450"
+ }
+ },
+ {
+ "id": "donut-spinner",
+ "title": "Donut spinner",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "donut-spinner.md",
+ "text": "Creates a donut spinner that can be used to indicate the loading of content.\n\n",
+ "explanation": "\n\nUse a semi-transparent `border` for the whole element, except one side that will\nserve as the loading indicator for the donut. Use `animation` to rotate the element.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Requires prefixes for full support. \n\n- https://caniuse.com/#feat=css-animation\n- https://caniuse.com/#feat=transforms2d\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": "@keyframes donut-spin {\r\n 0% {\r\n transform: rotate(0deg);\r\n }\r\n 100% {\r\n transform: rotate(360deg);\r\n }\r\n}\r\n.donut {\r\n display: inline-block;\r\n border: 4px solid rgba(0, 0, 0, 0.1);\r\n border-left-color: #7983ff;\r\n border-radius: 50%;\r\n width: 30px;\r\n height: 30px;\r\n animation: donut-spin 1.2s linear infinite;\r\n}",
+ "js": "",
+ "scopedCss": "@keyframes donut-spin {\n 0% {\n transform: rotate(0deg); }\n 100% {\n transform: rotate(360deg); } }\n\n[data-scope=\"donut-spinner\"] .donut {\n display: inline-block;\n border: 4px solid rgba(0, 0, 0, 0.1);\n border-left-color: #7983ff;\n border-radius: 50%;\n width: 30px;\n height: 30px;\n animation: donut-spin 1.2s linear infinite; }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "cf2af5a585eecb3c98ee07d02d2e94ebee5efdf01523313b61faa199309bee0d"
+ }
+ },
+ {
+ "id": "dynamic-shadow",
+ "title": "Dynamic shadow",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "dynamic-shadow.md",
+ "text": "Creates a shadow similar to `box-shadow` but based on the colors of the element itself.\n\n",
+ "explanation": "\n\n1. `position: relative` on the element establishes a Cartesian positioning context for psuedo-elements.\n2. `z-index: 1` establishes a new stacking context.\n3. `::after` defines a pseudo-element.\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 100%` and `height: 100%` sizes the pseudo-element to fill its parent's dimensions, making it equal in size.\n6. `background: inherit` causes the pseudo-element to inherit the linear gradient specified on the element.\n7. `top: 0.5rem` offsets the pseudo-element down slightly from its parent.\n8. `filter: blur(0.4rem)` will blur the pseudo-element to create the appearance of a shadow underneath.\n9. `opacity: 0.7` makes the pseudo-element partially transparent.\n10. `z-index: -1` positions the pseudo-element behind the parent but in front of the background.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Requires prefixes for full support. \n\n- https://caniuse.com/#feat=css-filters\n\n\n\n",
+ "supportPercentage": 98.46
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".dynamic-shadow {\r\n position: relative;\r\n width: 10rem;\r\n height: 10rem;\r\n background: linear-gradient(75deg, #6d78ff, #00ffb8);\r\n z-index: 1;\r\n}\r\n.dynamic-shadow::after {\r\n content: '';\r\n width: 100%;\r\n height: 100%;\r\n position: absolute;\r\n background: inherit;\r\n top: 0.5rem;\r\n filter: blur(0.4rem);\r\n opacity: 0.7;\r\n z-index: -1;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"dynamic-shadow\"] .dynamic-shadow {\n position: relative;\n width: 10rem;\n height: 10rem;\n background: linear-gradient(75deg, #6d78ff, #00ffb8);\n z-index: 1; }\n\n[data-scope=\"dynamic-shadow\"] .dynamic-shadow::after {\n content: '';\n width: 100%;\n height: 100%;\n position: absolute;\n background: inherit;\n top: 0.5rem;\n filter: blur(0.4rem);\n opacity: 0.7;\n z-index: -1; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "125c57e66fac5a5f0f231889d6cc2bbab0c8693070254386140468ec39045556"
+ }
+ },
+ {
+ "id": "easing-variables",
+ "title": "Easing variables",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "easing-variables.md",
+ "text": "Variables that can be reused for `transition-timing-function` properties, more\npowerful than the built-in `ease`, `ease-in`, `ease-out` and `ease-in-out`.\n\n",
+ "explanation": "\n\nThe variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document. In HTML, `:root` represents the `` element and is identical to the selector `html`, except that its specificity is higher.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-variables\n\n\n\n",
+ "supportPercentage": 96.51
+ },
+ "codeBlocks": {
+ "html": "Hover
",
+ "css": ":root {\r\n /* Place variables in here to use globally */\r\n}\r\n\r\n.easing-variables {\r\n --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);\r\n --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);\r\n --ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);\r\n --ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);\r\n --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);\r\n --ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);\r\n\r\n --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);\r\n --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);\r\n --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);\r\n --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);\r\n --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);\r\n --ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);\r\n\r\n --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);\r\n --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);\r\n --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);\r\n --ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1);\r\n --ease-in-out-expo: cubic-bezier(1, 0, 0, 1);\r\n --ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.15, 0.86);\r\n display: inline-block;\r\n width: 75px;\r\n height: 75px;\r\n padding: 10px;\r\n color: white;\r\n line-height: 50px;\r\n text-align: center;\r\n background: #333;\r\n transition: transform 1s var(--ease-out-quart);\r\n}\r\n\r\n.easing-variables:hover {\r\n transform: rotate(45deg);\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"easing-variables\"] :root {\n /* Place variables in here to use globally */ }\n\n[data-scope=\"easing-variables\"] .easing-variables {\n --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);\n --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);\n --ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);\n --ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);\n --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);\n --ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);\n --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);\n --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);\n --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);\n --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);\n --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);\n --ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);\n --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);\n --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);\n --ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);\n --ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1);\n --ease-in-out-expo: cubic-bezier(1, 0, 0, 1);\n --ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.15, 0.86);\n display: inline-block;\n width: 75px;\n height: 75px;\n padding: 10px;\n color: white;\n line-height: 50px;\n text-align: center;\n background: #333;\n transition: transform 1s var(--ease-out-quart); }\n\n[data-scope=\"easing-variables\"] .easing-variables:hover {\n transform: rotate(45deg); }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "742eec324f2b9eb3a5cf972639069523e1244ee95bc6335192587b8f9352f2da"
+ }
+ },
+ {
+ "id": "etched-text",
+ "title": "Etched text",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "etched-text.md",
+ "text": "Creates an effect where text appears to be \"etched\" or engraved into the background.\n\n",
+ "explanation": "\n\n`text-shadow: 0 2px white` creates a white shadow offset `0px` horizontally and `2px` vertically\nfrom the origin position.\n\nThe background must be darker than the shadow for the effect to work.\n\nThe text color should be slightly faded to make it look like it's engraved/carved out\nof the background.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-textshadow\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "I appear etched into the background.
",
+ "css": ".etched-text {\r\n text-shadow: 0 2px white;\r\n font-size: 1.5rem;\r\n font-weight: bold;\r\n color: #b8bec5;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"etched-text\"] .etched-text {\n text-shadow: 0 2px white;\n font-size: 1.5rem;\n font-weight: bold;\n color: #b8bec5; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "fade4c04ebb8c2e6d680cc803d54738dbb166b6f608f13a94eacfe0b762fb0c4"
+ }
+ },
+ {
+ "id": "evenly-distributed-children",
+ "title": "Evenly distributed children",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "evenly-distributed-children.md",
+ "text": "Evenly distributes child elements within a parent element.\n\n",
+ "explanation": "\n\n1. `display: flex` enables flexbox.\n2. `justify-content: space-between` evenly distributes child elements horizontally. The first item is positioned at the left edge, while the last item is positioned at the right edge.\n\nAlternatively, use `justify-content: space-around` to distribute the children with space around them, rather than between them.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Needs prefixes for full support. \n\n- https://caniuse.com/#feat=flexbox\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n
Item1
\r\n
Item2
\r\n
Item3
\r\n
",
+ "css": ".evenly-distributed-children {\r\n display: flex;\r\n justify-content: space-between;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"evenly-distributed-children\"] .evenly-distributed-children {\n display: flex;\n justify-content: space-between; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "3489ccfed45a24c536c275e7a74cc8727fd801baae9c2b5123265bcd75e70a37"
+ }
+ },
+ {
+ "id": "fit-image-in-container",
+ "title": "Fit image in container",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "fit-image-in-container.md",
+ "text": "Changes the fit and position of an image within its container while preserving its aspect ratio. Previously only possible using a background image and the `background-size` property.\n\n",
+ "explanation": "\n\n- `object-fit: contain` fits the entire image within the container while preserving its aspect ratio.\n- `object-fit: cover` fills the container with the image while preserving its aspect ratio.\n- `object-position: [x] [y]` positions the image within the container.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=object-fit\n",
+ "supportPercentage": 99.5
+ },
+ "codeBlocks": {
+ "html": " \r\n ",
+ "css": ".image {\r\n background: #34495e;\r\n border: 1px solid #34495e;\r\n width: 200px;\r\n height: 200px;\r\n}\r\n\r\n.image-contain {\r\n object-fit: contain;\r\n object-position: center;\r\n}\r\n\r\n.image-cover {\r\n object-fit: cover;\r\n object-position: right top;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"fit-image-in-container\"] .image {\n background: #34495e;\n border: 1px solid #34495e;\n width: 200px;\n height: 200px; }\n\n[data-scope=\"fit-image-in-container\"] .image-contain {\n object-fit: contain;\n object-position: center; }\n\n[data-scope=\"fit-image-in-container\"] .image-cover {\n object-fit: cover;\n object-position: right top; }\n"
+ },
+ "tags": [
+ "layout",
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "79cb705dc7ae6fbde94fac8dc3b273dda73be7a4739a2cdf9f160ad6f678133a"
+ }
+ },
+ {
+ "id": "flexbox-centering",
+ "title": "Flexbox centering",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "flexbox-centering.md",
+ "text": "Horizontally and vertically centers a child element within a parent element using `flexbox`.\n\n",
+ "explanation": "\n\n1. `display: flex` enables flexbox.\n2. `justify-content: center` centers the child horizontally.\n3. `align-items: center` centers the child vertically.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Needs prefixes for full support. \n\n- https://caniuse.com/#feat=flexbox\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "",
+ "css": ".flexbox-centering {\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n height: 100px;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"flexbox-centering\"] .flexbox-centering {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100px; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "ec62036188c484a98e832c45535eafbf528020f116a5aac0c853b56f6b91162e"
+ }
+ },
+ {
+ "id": "focus-within",
+ "title": "Focus Within",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "focus-within.md",
+ "text": "Changes the appearance of a form if any of its children are focused.\n\n",
+ "explanation": "\n\nThe 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.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Not supported in IE11 or the current version of Edge. \n\n\n\n- https://caniuse.com/#feat=css-focus-within\n\n\n\n",
+ "supportPercentage": 85.39
+ },
+ "codeBlocks": {
+ "html": "\r\n \r\n
",
+ "css": "form {\r\n border: 3px solid #2d98da;\r\n color: #000000;\r\n padding: 4px;\r\n}\r\n\r\nform:focus-within {\r\n background: #f7b731;\r\n color: #000000;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"focus-within\"] form {\n border: 3px solid #2d98da;\n color: #000000;\n padding: 4px; }\n\n[data-scope=\"focus-within\"] form:focus-within {\n background: #f7b731;\n color: #000000; }\n"
+ },
+ "tags": [
+ "visual",
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "db08a880101d0e82dd0263582e7b251d88450df278e7d79a0a544d1575580c55"
+ }
+ },
+ {
+ "id": "fullscreen",
+ "title": "Fullscreen",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "fullscreen.md",
+ "text": "The :fullscreen CSS pseudo-class represents an element that's displayed when the browser is in fullscreen mode.\n\n",
+ "explanation": "\n\n1. `fullscreen` CSS pseudo-class selector is used to select and style an element that is being displayed in fullscreen mode.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://developer.mozilla.org/en-US/docs/Web/CSS/:fullscreen\n- https://caniuse.com/#feat=fullscreen\n\n\n\n",
+ "supportPercentage": 99.11
+ },
+ "codeBlocks": {
+ "html": "\r\n
Click the button below to enter the element into fullscreen mode.
\r\n
I change color in fullscreen mode!
\r\n
\r\n
\r\n Go Full Screen!\r\n \r\n
",
+ "css": ".container {\r\n margin: 40px auto;\r\n max-width: 700px;\r\n}\r\n\r\n.element {\r\n padding: 20px;\r\n height: 300px;\r\n width: 100%;\r\n background-color: skyblue;\r\n}\r\n\r\n.element p {\r\n text-align: center;\r\n color: white;\r\n font-size: 3em;\r\n}\r\n\r\n.element:-ms-fullscreen p {\r\n visibility: visible;\r\n}\r\n\r\n.element:fullscreen {\r\n background-color: #e4708a;\r\n width: 100vw;\r\n height: 100vh;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"fullscreen\"] .container {\n margin: 40px auto;\n max-width: 700px; }\n\n[data-scope=\"fullscreen\"] .element {\n padding: 20px;\n height: 300px;\n width: 100%;\n background-color: skyblue; }\n\n[data-scope=\"fullscreen\"] .element p {\n text-align: center;\n color: white;\n font-size: 3em; }\n\n[data-scope=\"fullscreen\"] .element:-ms-fullscreen p {\n visibility: visible; }\n\n[data-scope=\"fullscreen\"] .element:fullscreen {\n background-color: #e4708a;\n width: 100vw;\n height: 100vh; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "2bb108851d15d46749ba4f1caa2ba08d4754a2ee988e812280925c637f610d40"
+ }
+ },
+ {
+ "id": "ghost-trick",
+ "title": "Ghost trick",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "ghost-trick.md",
+ "text": "Vertically centers an element in another.\n\n",
+ "explanation": "\n\nUse the style of a `:before` pseudo-element to vertically align inline elements without changing their `position` property.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=inline-block\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n
Vertically centered without changing the position property.
\r\n
",
+ "css": ".ghosting {\r\n height: 300px;\r\n background: #0ff;\r\n}\r\n\r\n.ghosting:before {\r\n content: '';\r\n display: inline-block;\r\n height: 100%;\r\n vertical-align: middle;\r\n}\r\n\r\np {\r\n display: inline-block;\r\n vertical-align: middle;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"ghost-trick\"] .ghosting {\n height: 300px;\n background: #0ff; }\n\n[data-scope=\"ghost-trick\"] .ghosting:before {\n content: '';\n display: inline-block;\n height: 100%;\n vertical-align: middle; }\n\n[data-scope=\"ghost-trick\"] p {\n display: inline-block;\n vertical-align: middle; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "622cd2ec51c26b37be3ea38a55d71bbb1b5944f14188b484c4903e23b45086c9"
+ }
+ },
+ {
+ "id": "gradient-text",
+ "title": "Gradient text",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "gradient-text.md",
+ "text": "Gives text a gradient color.\n\n",
+ "explanation": "\n\n1. `background: -webkit-linear-gradient(...)` gives the text element a gradient background.\n2. `webkit-text-fill-color: transparent` fills the text with a transparent color.\n3. `webkit-background-clip: text` clips the background with the text, filling the text with\n the gradient background as the color.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Uses non-standard properties. \n\n- https://caniuse.com/#feat=text-stroke\n\n\n\n",
+ "supportPercentage": 98.65
+ },
+ "codeBlocks": {
+ "html": "Gradient text
",
+ "css": ".gradient-text {\r\n background: -webkit-linear-gradient(pink, red);\r\n -webkit-text-fill-color: transparent;\r\n -webkit-background-clip: text;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"gradient-text\"] .gradient-text {\n background: -webkit-linear-gradient(pink, red);\n -webkit-text-fill-color: transparent;\n -webkit-background-clip: text; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "56a606934b50e0c3c53eb4819ee3fcb57344a9bd7dce91ae26c6f98c99a4c386"
+ }
+ },
+ {
+ "id": "grid-centering",
+ "title": "Grid centering",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "grid-centering.md",
+ "text": "Horizontally and vertically centers a child element within a parent element using `grid`.\n\n",
+ "explanation": "\n\n1. `display: grid` enables grid.\n2. `justify-content: center` centers the child horizontally.\n3. `align-items: center` centers the child vertically.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-grid\n\n\n\n",
+ "supportPercentage": 97.25999999999999
+ },
+ "codeBlocks": {
+ "html": "",
+ "css": ".grid-centering {\r\n display: grid;\r\n justify-content: center;\r\n align-items: center;\r\n height: 100px;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"grid-centering\"] .grid-centering {\n display: grid;\n justify-content: center;\n align-items: center;\n height: 100px; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "167267471e09e52f20ed40ffb23b8efa1cfba6434fea5b7c82810c62c8ba5ee0"
+ }
+ },
+ {
+ "id": "hairline-border",
+ "title": "Hairline border",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "hairline-border.md",
+ "text": "Gives an element a border equal to 1 native device pixel in width, which can look\nvery sharp and crisp.\n\n",
+ "explanation": "\n\n1. `box-shadow`, when only using spread, adds a pseudo-border which can use subpixels\\*.\n2. Use `@media (min-resolution: ...)` to check the device pixel ratio (`1dppx` equals 96 DPI),\n setting the spread of the `box-shadow` equal to `1 / dppx`.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Needs alternate syntax and JavaScript user agent checking for full support. \n\n- https://caniuse.com/#feat=css-boxshadow\n- https://caniuse.com/#feat=css-media-resolution\n\n \n\n\\*Chrome does not support subpixel values on `border`. Safari does not support subpixel values on `box-shadow`. Firefox supports subpixel values on both.\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "text
",
+ "css": ".hairline-border {\r\n box-shadow: 0 0 0 1px;\r\n}\r\n\r\n@media (min-resolution: 2dppx) {\r\n .hairline-border {\r\n box-shadow: 0 0 0 0.5px;\r\n }\r\n}\r\n\r\n@media (min-resolution: 3dppx) {\r\n .hairline-border {\r\n box-shadow: 0 0 0 0.33333333px;\r\n }\r\n}\r\n\r\n@media (min-resolution: 4dppx) {\r\n .hairline-border {\r\n box-shadow: 0 0 0 0.25px;\r\n }\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 1px; }\n\n@media (min-resolution: 2dppx) {\n [data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 0.5px; } }\n\n@media (min-resolution: 3dppx) {\n [data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 0.33333333px; } }\n\n@media (min-resolution: 4dppx) {\n [data-scope=\"hairline-border\"] .hairline-border {\n box-shadow: 0 0 0 0.25px; } }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "0e45709255d9ca14598c5fa54c2ae5490f81a0ef67c466d6d678da584340428b"
+ }
+ },
+ {
+ "id": "height-transition",
+ "title": "Height transition",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "height-transition.md",
+ "text": "Transitions an element's height from `0` to `auto` when its height is unknown.\n\n",
+ "explanation": "\n\n1. `transition: max-height: 0.5s cubic-bezier(...)` specifies that changes to `max-height` should be transitioned over 0.5 seconds, using an `ease-out-quint` timing function.\n2. `overflow: hidden` prevents the contents of the hidden element from overflowing its container.\n3. `max-height: 0` specifies that the element has no height initially.\n4. `.target:hover > .el` specifies that when the parent is hovered over, target a child `.el` within\n it and use the `--max-height` variable which was defined by JavaScript.\n---\n1. `el.scrollHeight` is the height of the element including overflow, which will change dynamically\n based on the content of the element.\n2. `el.style.setProperty(...)` sets the `--max-height` CSS variable which is used to specify the `max-height` of the element the target is hovered over, allowing it to transition smoothly from 0 to auto.\n\n",
+ "browserSupport": {
+ "text": "\n\nRequires JavaScript
\n\n ⚠️ Causes reflow on each animation frame, which will be laggy if there are a large number of elements\n beneath the element that is transitioning in height.\n \n\n- https://caniuse.com/#feat=css-variables\n- https://caniuse.com/#feat=css-transitions\n\n\n\n",
+ "supportPercentage": 96.51
+ },
+ "codeBlocks": {
+ "html": "\r\n Hover me to see a height transition.\r\n
content
\r\n
",
+ "css": ".el {\r\n transition: max-height 0.5s;\r\n overflow: hidden;\r\n max-height: 0;\r\n}\r\n\r\n.trigger:hover > .el {\r\n max-height: var(--max-height);\r\n}",
+ "js": "var el = document.querySelector('.el')\r\nvar height = el.scrollHeight\r\nel.style.setProperty('--max-height', height + 'px')",
+ "scopedCss": "[data-scope=\"height-transition\"] .el {\n transition: max-height 0.5s;\n overflow: hidden;\n max-height: 0; }\n\n[data-scope=\"height-transition\"] .trigger:hover > .el {\n max-height: var(--max-height); }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "7ee6c8c6027ccbba77e7c02bdb79cf22a0d22d7acece1ea5408da19a7f986d7a"
+ }
+ },
+ {
+ "id": "hover-shadow-box-animation",
+ "title": "Hover shadow box animation",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "hover-shadow-box-animation.md",
+ "text": "Creates a shadow box around the text when it is hovered.\n\n",
+ "explanation": "\n\n1. `display: inline-block` to set width and length for `p` element thus making it an `inline-block`.\n2. Set `transform: perspective(1px)` to give element a 3D space by affecting the distance between the Z plane and the user and `translate(0)` to reposition the `p` element along z-axis in 3D space.\n3. `box-shadow:` to set up the box.\n4. `transparent` to make box transparent.\n5. `transition-property` to enable transitions for both `box-shadow` and `transform`.\n6. `:hover` to activate whole css when hovering is done until `active`.\n7. `transform: scale(1.2)` to change the scale, magnifying the text.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=transforms3d\n- https://caniuse.com/#feat=css-transitions\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "Box it!
",
+ "css": ".hover-shadow-box-animation {\r\n display: inline-block;\r\n vertical-align: middle;\r\n transform: perspective(1px) translateZ(0);\r\n box-shadow: 0 0 1px transparent;\r\n margin: 10px;\r\n transition-duration: 0.3s;\r\n transition-property: box-shadow, transform;\r\n}\r\n.hover-shadow-box-animation:hover,\r\n.hover-shadow-box-animation:focus,\r\n.hover-shadow-box-animation:active {\r\n box-shadow: 1px 10px 10px -10px rgba(0, 0, 24, 0.5);\r\n transform: scale(1.2);\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation {\n display: inline-block;\n vertical-align: middle;\n transform: perspective(1px) translateZ(0);\n box-shadow: 0 0 1px transparent;\n margin: 10px;\n transition-duration: 0.3s;\n transition-property: box-shadow, transform; }\n\n[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation:hover,\n[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation:focus,\n[data-scope=\"hover-shadow-box-animation\"] .hover-shadow-box-animation:active {\n box-shadow: 1px 10px 10px -10px rgba(0, 0, 24, 0.5);\n transform: scale(1.2); }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "8fc3c2c5fc4248b2ec6bfdbc96cb5912936ccd5865d88da7a3a041a32168968a"
+ }
+ },
+ {
+ "id": "hover-underline-animation",
+ "title": "Hover underline animation",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "hover-underline-animation.md",
+ "text": "Creates an animated underline effect when the text is hovered over.\n\n**Credit:** https://flatuicolors.com/ \n\n",
+ "explanation": "\n\n1. `display: inline-block` makes the block `p` an `inline-block` to prevent the underline from\n spanning the entire parent width rather than just the content (text).\n2. `position: relative` on the element establishes a Cartesian positioning context for pseudo-elements.\n3. `::after` defines a pseudo-element.\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 100%` ensures the pseudo-element spans the entire width of the text block.\n6. `transform: scaleX(0)` initially scales the pseudo element to 0 so it has no width and is not visible.\n7. `bottom: 0` and `left: 0` position it to the bottom left of the block.\n8. `transition: transform 0.25s ease-out` means changes to `transform` will be transitioned over 0.25 seconds\n with an `ease-out` timing function.\n9. `transform-origin: bottom right` means the transform anchor point is positioned at the bottom right of the block.\n10. `:hover::after` then uses `scaleX(1)` to transition the width to 100%, then changes the `transform-origin`\n to `bottom left` so that the anchor point is reversed, allowing it transition out in the other direction when\n hovered off.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=transforms2d\n- https://caniuse.com/#feat=css-transitions\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "Hover this text to see the effect!
",
+ "css": ".hover-underline-animation {\r\n display: inline-block;\r\n position: relative;\r\n color: #0087ca;\r\n}\r\n.hover-underline-animation::after {\r\n content: '';\r\n position: absolute;\r\n width: 100%;\r\n transform: scaleX(0);\r\n height: 2px;\r\n bottom: 0;\r\n left: 0;\r\n background-color: #0087ca;\r\n transform-origin: bottom right;\r\n transition: transform 0.25s ease-out;\r\n}\r\n.hover-underline-animation:hover::after {\r\n transform: scaleX(1);\r\n transform-origin: bottom left;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"hover-underline-animation\"] .hover-underline-animation {\n display: inline-block;\n position: relative;\n color: #0087ca; }\n\n[data-scope=\"hover-underline-animation\"] .hover-underline-animation::after {\n content: '';\n position: absolute;\n width: 100%;\n transform: scaleX(0);\n height: 2px;\n bottom: 0;\n left: 0;\n background-color: #0087ca;\n transform-origin: bottom right;\n transition: transform 0.25s ease-out; }\n\n[data-scope=\"hover-underline-animation\"] .hover-underline-animation:hover::after {\n transform: scaleX(1);\n transform-origin: bottom left; }\n"
+ },
+ "tags": [
+ "animation",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "5ee579737769cd734df27df60b3c0fa296965192f1cdca45d4c43a414c6b9760"
+ }
+ },
+ {
+ "id": "last-item-with-remaining-available-height",
+ "title": "Last item with remaining available height",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "last-item-with-remaining-available-height.md",
+ "text": "Take advantage of available viewport space by giving the last element the remaining available space in current viewport, even when resizing the window.\n\n",
+ "explanation": "\n\n1. `height: 100%` set the height of container as viewport height.\n2. `display: flex` enables flexbox.\n3. `flex-direction: column` set the direction of flex items' order from top to down.\n4. `flex-grow: 1` the flexbox will apply remaining available space of container to last child element.\n\nThe parent must have a viewport height. `flex-grow: 1` could be applied to the first or second element, which will have all available space.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Needs prefixes for full support. \n\n- https://caniuse.com/#feat=flexbox\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n
Div 1
\r\n
Div 2
\r\n
Div 3
\r\n
",
+ "css": "html,\r\nbody {\r\n height: 100%;\r\n margin: 0;\r\n}\r\n\r\n.container {\r\n height: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n}\r\n\r\n.container > div:last-child {\r\n background-color: tomato;\r\n flex: 1;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"last-item-with-remaining-available-height\"] html,\n[data-scope=\"last-item-with-remaining-available-height\"] body {\n height: 100%;\n margin: 0; }\n\n[data-scope=\"last-item-with-remaining-available-height\"] .container {\n height: 100%;\n display: flex;\n flex-direction: column; }\n\n[data-scope=\"last-item-with-remaining-available-height\"] .container > div:last-child {\n background-color: tomato;\n flex: 1; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "522a5e309cea7f772600ca1d5f89ee911f0aec94b157e2adb94ac3f479445c01"
+ }
+ },
+ {
+ "id": "mouse-cursor-gradient-tracking",
+ "title": "Mouse cursor gradient tracking",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "mouse-cursor-gradient-tracking.md",
+ "text": "A hover effect where the gradient follows the mouse cursor.\n\n**Credit:** [Tobias Reich](https://codepen.io/electerious/pen/MQrRxX) \n\n",
+ "explanation": "\n\n1. `--x` and `--y` are used to track the position of the mouse on the button.\n2. `--size` is used to keep modify of the gradient's dimensions.\n3. `background: radial-gradient(circle closest-side, pink, transparent);` creates the gradient at the correct postion.\n\n",
+ "browserSupport": {
+ "text": "\n\nRequires JavaScript
\n⚠️ Requires JavaScript. \n\n- https://caniuse.com/#feat=css-variables\n\n\n\n",
+ "supportPercentage": 96.51
+ },
+ "codeBlocks": {
+ "html": "Hover me ",
+ "css": ".mouse-cursor-gradient-tracking {\r\n position: relative;\r\n background: #7983ff;\r\n padding: 0.5rem 1rem;\r\n font-size: 1.2rem;\r\n border: none;\r\n color: white;\r\n cursor: pointer;\r\n outline: none;\r\n overflow: hidden;\r\n}\r\n\r\n.mouse-cursor-gradient-tracking span {\r\n position: relative;\r\n}\r\n\r\n.mouse-cursor-gradient-tracking::before {\r\n --size: 0;\r\n content: '';\r\n position: absolute;\r\n left: var(--x);\r\n top: var(--y);\r\n width: var(--size);\r\n height: var(--size);\r\n background: radial-gradient(circle closest-side, pink, transparent);\r\n transform: translate(-50%, -50%);\r\n transition: width 0.2s ease, height 0.2s ease;\r\n}\r\n\r\n.mouse-cursor-gradient-tracking:hover::before {\r\n --size: 200px;\r\n}",
+ "js": "var btn = document.querySelector('.mouse-cursor-gradient-tracking')\r\nbtn.onmousemove = function(e) {\r\n var x = e.pageX - btn.offsetLeft - btn.offsetParent.offsetLeft\r\n var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop\r\n btn.style.setProperty('--x', x + 'px')\r\n btn.style.setProperty('--y', y + 'px')\r\n}",
+ "scopedCss": "[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking {\n position: relative;\n background: #7983ff;\n padding: 0.5rem 1rem;\n font-size: 1.2rem;\n border: none;\n color: white;\n cursor: pointer;\n outline: none;\n overflow: hidden; }\n\n[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking span {\n position: relative; }\n\n[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking::before {\n --size: 0;\n content: '';\n position: absolute;\n left: var(--x);\n top: var(--y);\n width: var(--size);\n height: var(--size);\n background: radial-gradient(circle closest-side, pink, transparent);\n transform: translate(-50%, -50%);\n transition: width 0.2s ease, height 0.2s ease; }\n\n[data-scope=\"mouse-cursor-gradient-tracking\"] .mouse-cursor-gradient-tracking:hover::before {\n --size: 200px; }\n"
+ },
+ "tags": [
+ "visual",
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "707e50fd348545fc1f9950ef9cda9e74b28ffe57098cc2849c72358c4bf7bea6"
+ }
+ },
+ {
+ "id": "not-selector",
+ "title": ":not selector",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "not-selector.md",
+ "text": "The `:not` psuedo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.\n\n",
+ "explanation": "\n\n`li:not(:last-child)` specifies that the styles should apply to all `li` elements except\nthe `:last-child`.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-sel3\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n One \r\n Two \r\n Three \r\n Four \r\n ",
+ "css": ".css-not-selector-shortcut {\r\n display: flex;\r\n}\r\n\r\nul {\r\n padding-left: 0;\r\n}\r\n\r\nli {\r\n list-style-type: none;\r\n margin: 0;\r\n padding: 0 0.75rem;\r\n}\r\n\r\nli:not(:last-child) {\r\n border-right: 2px solid #d2d5e4;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"not-selector\"] .css-not-selector-shortcut {\n display: flex; }\n\n[data-scope=\"not-selector\"] ul {\n padding-left: 0; }\n\n[data-scope=\"not-selector\"] li {\n list-style-type: none;\n margin: 0;\n padding: 0 0.75rem; }\n\n[data-scope=\"not-selector\"] li:not(:last-child) {\n border-right: 2px solid #d2d5e4; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "7d2727a78b8ee2a55a823116fb01099efa227952d8fba8c35a1d3067675985d5"
+ }
+ },
+ {
+ "id": "offscreen",
+ "title": "Offscreen",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "offscreen.md",
+ "text": "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.\n\n",
+ "explanation": "\n\n1. Remove all borders.\n2. Use `clip` to indicate that no part of the element should be shown.\n3. Make the height and width of the element 1px.\n4. Negate the elements height and width using `margin: -1px`.\n5. Hide the element's overflow.\n6. Remove all padding.\n7. Position the element absolutely so that it does not take up space in the DOM.\n\n",
+ "browserSupport": {
+ "text": "\n\n(Although `clip` technically has been depreciated, the newer `clip-path` currently has very limited browser support.)\n\n- https://caniuse.com/#search=clip\n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "\r\n Learn More about pants \r\n ",
+ "css": ".offscreen {\r\n border: 0;\r\n clip: rect(0 0 0 0);\r\n height: 1px;\r\n margin: -1px;\r\n overflow: hidden;\r\n padding: 0;\r\n position: absolute;\r\n width: 1px;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"offscreen\"] .offscreen {\n border: 0;\n clip: rect(0 0 0 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px; }\n"
+ },
+ "tags": [
+ "layout",
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "000a1fd47f9dafba64a625aefc689e33592adf69c8c5ecffb6de68a83f0218aa"
+ }
+ },
+ {
+ "id": "overflow-scroll-gradient",
+ "title": "Overflow scroll gradient",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "overflow-scroll-gradient.md",
+ "text": "Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled.\n\n",
+ "explanation": "\n\n1. `position: relative` on the parent establishes a Cartesian positioning context for pseudo-elements.\n2. `::after` defines a pseudo element.\n3. `background-image: linear-gradient(...)` adds a linear gradient that fades from transparent to white\n (top to bottom).\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 240px` matches the size of the scrolling element (which is a child of the parent that has\n the pseudo element).\n6. `height: 25px` is the height of the fading gradient pseudo-element, which should be kept relatively small.\n7. `bottom: 0` positions the pseudo-element at the bottom of the parent.\n8. `pointer-events: none` specifies that the pseudo-element cannot be a target of mouse events, allowing text behind it to still be selectable/interactive.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-gradients\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "",
+ "css": ".overflow-scroll-gradient {\r\n position: relative;\r\n}\r\n.overflow-scroll-gradient::after {\r\n content: '';\r\n position: absolute;\r\n bottom: 0;\r\n width: 240px;\r\n height: 25px;\r\n background: linear-gradient(\r\n rgba(255, 255, 255, 0.001),\r\n white\r\n ); /* transparent keyword is broken in Safari */\r\n pointer-events: none;\r\n}\r\n.overflow-scroll-gradient__scroller {\r\n overflow-y: scroll;\r\n background: white;\r\n width: 240px;\r\n height: 200px;\r\n padding: 15px;\r\n line-height: 1.2;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"overflow-scroll-gradient\"] .overflow-scroll-gradient {\n position: relative; }\n\n[data-scope=\"overflow-scroll-gradient\"] .overflow-scroll-gradient::after {\n content: '';\n position: absolute;\n bottom: 0;\n width: 240px;\n height: 25px;\n background: linear-gradient(rgba(255, 255, 255, 0.001), white);\n /* transparent keyword is broken in Safari */\n pointer-events: none; }\n\n[data-scope=\"overflow-scroll-gradient\"] .overflow-scroll-gradient__scroller {\n overflow-y: scroll;\n background: white;\n width: 240px;\n height: 200px;\n padding: 15px;\n line-height: 1.2; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "6ce90f10b574780c196faad6a498c8d5b1e5e2d6c3464ded47ceb1056b24baa3"
+ }
+ },
+ {
+ "id": "popout-menu",
+ "title": "Popout menu",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "popout-menu.md",
+ "text": "Reveals an interactive popout menu on hover and focus.\n\n",
+ "explanation": "\n\n1. `position: relative` on the reference parent establishes a Cartesian positioning context for its child.\n2. `position: absolute` takes the popout menu out of the flow of the document and positions it in relation to the parent.\n3. `left: 100%` moves the the popout menu 100% of its parent's width from the left.\n4. `visibility: hidden` hides the popout menu initially and allows for transitions (unlike `display: none`).\n5. `.reference:hover > .popout-menu` means that when `.reference` is hovered over, select immediate children with a class of `.popout-menu` and change their `visibility` to `visible`, which shows the popout.\n6. `.reference:focus > .popout-menu` means that when `.reference` is focused, the popout would be shown.\n7. `.reference:focus-within > .popout-menu` ensures that the popout is shown when the focus is _within_ the reference.\n\n",
+ "browserSupport": {
+ "text": "\n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".reference {\r\n position: relative;\r\n background: tomato;\r\n width: 100px;\r\n height: 100px;\r\n}\r\n.popout-menu {\r\n position: absolute;\r\n visibility: hidden;\r\n left: 100%;\r\n background: #333;\r\n color: white;\r\n padding: 15px;\r\n}\r\n.reference:hover > .popout-menu,\r\n.reference:focus > .popout-menu,\r\n.reference:focus-within > .popout-menu {\r\n visibility: visible;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"popout-menu\"] .reference {\n position: relative;\n background: tomato;\n width: 100px;\n height: 100px; }\n\n[data-scope=\"popout-menu\"] .popout-menu {\n position: absolute;\n visibility: hidden;\n left: 100%;\n background: #333;\n color: white;\n padding: 15px; }\n\n[data-scope=\"popout-menu\"] .reference:hover > .popout-menu,\n[data-scope=\"popout-menu\"] .reference:focus > .popout-menu,\n[data-scope=\"popout-menu\"] .reference:focus-within > .popout-menu {\n visibility: visible; }\n"
+ },
+ "tags": [
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "8f5c19fb14ee8039e93ff0f3185cb0d27971dd2509f6100fdfd290478211a42b"
+ }
+ },
+ {
+ "id": "pretty-text-underline",
+ "title": "Pretty text underline",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "pretty-text-underline.md",
+ "text": "A nicer alternative to `text-decoration: underline` or ` ` where descenders do not clip the underline.\nNatively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline.\n\n",
+ "explanation": "\n\n1. `text-shadow` uses 4 values with offsets that cover a 4x4 px area to ensure the underline\n has a \"thick\" shadow that covers the line where descenders clip it. Use a color\n that matches the background. For a larger font, use a larger `px` size. Additional values\n can create an even thicker shadow, and subpixel values can also be used.\n2. `background-image: linear-gradient(...)` creates a 90deg gradient using the\n text color (`currentColor`).\n3. The `background-*` properties size the gradient as 100% of the width of the block and 1px\n in height at the bottom and disables repetition, which creates a 1px underline beneath\n the text.\n4. The `::selection` pseudo selector rule ensures the text shadow does not interfere with text\n selection.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-textshadow\n- https://caniuse.com/#feat=css-gradients\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "Pretty text underline without clipping descending letters.
",
+ "css": ".pretty-text-underline {\r\n display: inline;\r\n text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;\r\n background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);\r\n background-position: bottom;\r\n background-repeat: no-repeat;\r\n background-size: 100% 1px;\r\n}\r\n.pretty-text-underline::-moz-selection {\r\n background-color: rgba(0, 150, 255, 0.3);\r\n text-shadow: none;\r\n}\r\n.pretty-text-underline::selection {\r\n background-color: rgba(0, 150, 255, 0.3);\r\n text-shadow: none;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"pretty-text-underline\"] .pretty-text-underline {\n display: inline;\n text-shadow: 1px 1px #f5f6f9, -1px 1px #f5f6f9, -1px -1px #f5f6f9, 1px -1px #f5f6f9;\n background-image: linear-gradient(90deg, currentColor 100%, transparent 100%);\n background-position: bottom;\n background-repeat: no-repeat;\n background-size: 100% 1px; }\n\n[data-scope=\"pretty-text-underline\"] .pretty-text-underline::-moz-selection {\n background-color: rgba(0, 150, 255, 0.3);\n text-shadow: none; }\n\n[data-scope=\"pretty-text-underline\"] .pretty-text-underline::selection {\n background-color: rgba(0, 150, 255, 0.3);\n text-shadow: none; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "5d0eb22cb50d397c88c5f3a111a6a85d6cfa7d61fb7e88c966fdd55fe9d5b587"
+ }
+ },
+ {
+ "id": "reset-all-styles",
+ "title": "Reset all styles",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "reset-all-styles.md",
+ "text": "Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties.\n\n",
+ "explanation": "\n\nThe `all` property allows you to reset all styles (inherited or not) to default values.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ MS Edge status is under consideration. \n\n- https://caniuse.com/#feat=css-all\n\n\n\n",
+ "supportPercentage": 95.76
+ },
+ "codeBlocks": {
+ "html": "\r\n
Title \r\n
\r\n Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure id exercitationem nulla qui\r\n repellat laborum vitae, molestias tempora velit natus. Quas, assumenda nisi. Quisquam enim qui\r\n iure, consequatur velit sit?\r\n
\r\n
",
+ "css": ".reset-all-styles {\r\n all: initial;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"reset-all-styles\"] .reset-all-styles {\n all: initial; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "d601816311504b7521c8bba212e2c4b6fb50317ec10df60991a414bae1c82bf9"
+ }
+ },
+ {
+ "id": "shape-separator",
+ "title": "Shape separator",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "shape-separator.md",
+ "text": "Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.\n\n",
+ "explanation": "\n\n1. `position: relative` on the element establishes a Cartesian positioning context for pseudo elements.\n2. `::after` defines a pseudo element.\n3. `background-image: url(...)` adds the SVG shape (a 24x12 triangle) as the background image of the pseudo element, which repeats by default. It must be the same color as the block that is being separated. For other shapes, we can use [the URL-encoder for SVG](http://yoksel.github.io/url-encoder/).\n4. `position: absolute` takes the pseudo element out of the flow of the document and positions it in relation to the parent.\n5. `width: 100%` ensures the element stretches the entire width of its parent.\n6. `height: 12px` is the same height as the shape.\n7. `bottom: 0` positions the pseudo element at the bottom of the parent.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=svg\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".shape-separator {\r\n position: relative;\r\n height: 48px;\r\n background: #333;\r\n}\r\n.shape-separator::after {\r\n content: '';\r\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='m12 0l12 12h-24z' fill='%23fff'/%3E%3C/svg%3E\");\r\n position: absolute;\r\n width: 100%;\r\n height: 12px;\r\n bottom: 0;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"shape-separator\"] .shape-separator {\n position: relative;\n height: 48px;\n background: #333; }\n\n[data-scope=\"shape-separator\"] .shape-separator::after {\n content: '';\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='m12 0l12 12h-24z' fill='%23fff'/%3E%3C/svg%3E\");\n position: absolute;\n width: 100%;\n height: 12px;\n bottom: 0; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "1ce90fc518399c775df1af832345729bdde2a3c12bbdd2fd66c40b9c57a65aa1"
+ }
+ },
+ {
+ "id": "sibling-fade",
+ "title": "Sibling fade",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "sibling-fade.md",
+ "text": "Fades out the siblings of a hovered item.\n\n",
+ "explanation": "\n\n1. `transition: opacity 0.2s` specifies that changes to opacity will be transitioned over 0.2 seconds.\n2. `.sibling-fade:hover span:not(:hover)` specifies that when the parent is hovered, select any `span` children\n that are not currently being hovered and change their opacity to `0.5`.\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-sel3\n- https://caniuse.com/#feat=css-transitions\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n Item 1 Item 2 Item 3 Item 4 \r\n Item 5 Item 6 \r\n
",
+ "css": "span {\r\n padding: 0 1rem;\r\n transition: opacity 0.2s;\r\n}\r\n\r\n.sibling-fade:hover span:not(:hover) {\r\n opacity: 0.5;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"sibling-fade\"] span {\n padding: 0 1rem;\n transition: opacity 0.2s; }\n\n[data-scope=\"sibling-fade\"] .sibling-fade:hover span:not(:hover) {\n opacity: 0.5; }\n"
+ },
+ "tags": [
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "a1e353f0dc466a24881986bbaf8f2cd9f367fe80d54ac8e1481d82e021236389"
+ }
+ },
+ {
+ "id": "system-font-stack",
+ "title": "System font stack",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "system-font-stack.md",
+ "text": "Uses the native font of the operating system to get close to a native app feel.\n\n",
+ "explanation": "\n\nThe browser looks for each successive font, preferring the first one if possible, and\nfalls back to the next if it cannot find the font (on the system or defined in CSS).\n\n1. `-apple-system` is San Francisco, used on iOS and macOS (not Chrome however)\n2. `BlinkMacSystemFont` is San Francisco, used on macOS Chrome\n3. `Segoe UI` is used on Windows 10\n4. `Roboto` is used on Android\n5. `Oxygen-Sans` is used on Linux with KDE\n6. `Ubuntu` is used on Ubuntu (all variants)\n7. `Cantarell` is used on Linux with GNOME Shell\n8. `\"Helvetica Neue\"` and `Helvetica` is used on macOS 10.10 and below (wrapped in quotes because it has a space)\n9. `Arial` is a font widely supported by all operating systems\n10. `sans-serif` is the fallback sans-serif font if none of the other fonts are supported\n\n",
+ "browserSupport": {
+ "text": "\n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "This text uses the system font.
",
+ "css": ".system-font-stack {\r\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,\r\n Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"system-font-stack\"] .system-font-stack {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,\r Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "0a35134bd1fe1da354810ef3228f50a81105997c0e81138c97cc9ace399adbb2"
+ }
+ },
+ {
+ "id": "toggle-switch",
+ "title": "Toggle switch",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "toggle-switch.md",
+ "text": "Creates a toggle switch with CSS only.\n\n",
+ "explanation": "\n\nThis effect is styling only the `` element to look like a toggle switch, and hiding the actual ` ` checkbox by positioning it offscreen. When clicking the label associated with the ` ` element, it sets the ` ` checkbox into the `:checked` state.\n\n1. The `for` attribute associates the `` with the appropriate ` ` checkbox element by its `id`.\n2. `.switch::after` defines a pseudo-element for the `` to create the circular knob.\n3. `input[type='checkbox']:checked + .switch::after` targets the ``'s pseudo-element's style when the checkbox is `checked`.\n4. `transform: translateX(20px)` moves the pseudo-element (knob) 20px to the right when the checkbox is `checked`.\n5. `background-color: #7983ff;` sets the background-color of the switch to a different color when the checkbox is `checked`.\n6. `.offscreen` moves the ` ` checkbox element, which does not comprise any part of the actual toggle switch, out of the flow of document and positions it far away from the view, but does not hide it so it is accessible via keyboard and screen readers.\n7. `transition: all 0.3s` specifies all property changes will be transitioned over 0.3 seconds, therefore transitioning the ``'s `background-color` and the pseudo-element's `transform` property when the checkbox is checked.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Requires prefixes for full support. \n\n- https://caniuse.com/#feat=transforms2d\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": " ",
+ "css": ".switch {\r\n position: relative;\r\n display: inline-block;\r\n width: 40px;\r\n height: 20px;\r\n background-color: rgba(0, 0, 0, 0.25);\r\n border-radius: 20px;\r\n transition: all 0.3s;\r\n}\r\n\r\n.switch::after {\r\n content: '';\r\n position: absolute;\r\n width: 18px;\r\n height: 18px;\r\n border-radius: 18px;\r\n background-color: white;\r\n top: 1px;\r\n left: 1px;\r\n transition: all 0.3s;\r\n}\r\n\r\ninput[type='checkbox']:checked + .switch::after {\r\n transform: translateX(20px);\r\n}\r\n\r\ninput[type='checkbox']:checked + .switch {\r\n background-color: #7983ff;\r\n}\r\n\r\n.offscreen {\r\n position: absolute;\r\n left: -9999px;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"toggle-switch\"] .switch {\n position: relative;\n display: inline-block;\n width: 40px;\n height: 20px;\n background-color: rgba(0, 0, 0, 0.25);\n border-radius: 20px;\n transition: all 0.3s; }\n\n[data-scope=\"toggle-switch\"] .switch::after {\n content: '';\n position: absolute;\n width: 18px;\n height: 18px;\n border-radius: 18px;\n background-color: white;\n top: 1px;\n left: 1px;\n transition: all 0.3s; }\n\n[data-scope=\"toggle-switch\"] input[type='checkbox']:checked + .switch::after {\n transform: translateX(20px); }\n\n[data-scope=\"toggle-switch\"] input[type='checkbox']:checked + .switch {\n background-color: #7983ff; }\n\n[data-scope=\"toggle-switch\"] .offscreen {\n position: absolute;\n left: -9999px; }\n"
+ },
+ "tags": [
+ "visual",
+ "interactivity",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "6af55186736cae8da52a2a92bf7dcf56f6f23ca49ce083ad6653e373fa2d152e"
+ }
+ },
+ {
+ "id": "transform-centering",
+ "title": "Transform centering",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "transform-centering.md",
+ "text": "Vertically and horizontally centers a child element within its parent element using `position: absolute` and `transform: translate()` (as an alternative to `flexbox` or `display: table`). Similar to `flexbox`, this method does not require you to know the height or width of your parent or child so it is ideal for responsive applications.\n\n",
+ "explanation": "\n\n1. `position: absolute` on the child element allows it to be positioned based on its containing block.\n2. `left: 50%` and `top: 50%` offsets the child 50% from the left and top edge of its containing block.\n3. `transform: translate(-50%, -50%)` allows the height and width of the child element to be negated so that it is vertically and horizontally centered.\n\nNote: Fixed height and width on parent element is for the demo only.\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Requires prefix for full support. \n\n- https://caniuse.com/#feat=transforms2d\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "",
+ "css": ".parent {\r\n border: 1px solid #333;\r\n height: 250px;\r\n position: relative;\r\n width: 250px;\r\n}\r\n\r\n.child {\r\n left: 50%;\r\n position: absolute;\r\n top: 50%;\r\n transform: translate(-50%, -50%);\r\n text-align: center;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"transform-centering\"] .parent {\n border: 1px solid #333;\n height: 250px;\n position: relative;\n width: 250px; }\n\n[data-scope=\"transform-centering\"] .child {\n left: 50%;\n position: absolute;\n top: 50%;\n transform: translate(-50%, -50%);\n text-align: center; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "67b5f73d1e7aa4850b39c461fd93a548e106569554cf6e87f2a9981ecfb77ad1"
+ }
+ },
+ {
+ "id": "triangle",
+ "title": "Triangle",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "triangle.md",
+ "text": "Creates a triangle shape with pure CSS.\n\n",
+ "explanation": "\n\n[View this link for a detailed explanation.](https://stackoverflow.com/q/7073484)\n\nThe color of the border is the color of the triangle. The side the triangle tip points\ncorresponds to the opposite `border-*` property. For example, a color on `border-top`\nmeans the arrow points downward.\n\nExperiment with the `px` values to change the proportion of the triangle.\n\n",
+ "browserSupport": {
+ "text": "\n\n\n\n",
+ "supportPercentage": null
+ },
+ "codeBlocks": {
+ "html": "
",
+ "css": ".triangle {\r\n width: 0;\r\n height: 0;\r\n border-top: 20px solid #333;\r\n border-left: 20px solid transparent;\r\n border-right: 20px solid transparent;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"triangle\"] .triangle {\n width: 0;\n height: 0;\n border-top: 20px solid #333;\n border-left: 20px solid transparent;\n border-right: 20px solid transparent; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "d585e568bd1b8ca9c8a7d2fa52682c80249bf1e6055316bc3526ee54d8d26fb9"
+ }
+ },
+ {
+ "id": "truncate-text-multiline",
+ "title": "Truncate text multiline",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "truncate-text-multiline.md",
+ "text": "If the text is longer than one line, it will be truncated for `n` lines and end with an gradient fade.\n\n",
+ "explanation": "\n\n1. `overflow: hidden` prevents the text from overflowing its dimensions\n (for a block, 100% width and auto height).\n2. `width: 400px` ensures the element has a dimension.\n3. `height: 109.2px` calculated value for height, it equals `font-size * line-height * numberOfLines` (in this case `26 * 1.4 * 3 = 109.2`)\n4. `height: 36.4px` calculated value for gradient container, it equals `font-size * line-height` (in this case `26 * 1.4 = 36.4`)\n5. `background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%)` gradient from `transparent` to `#f5f6f9`\n\n",
+ "browserSupport": {
+ "text": "\n\n- https://caniuse.com/#feat=css-gradients\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut\r\n labore et.\r\n
",
+ "css": ".truncate-text-multiline {\r\n overflow: hidden;\r\n display: block;\r\n height: 109.2px;\r\n margin: 0 auto;\r\n font-size: 26px;\r\n line-height: 1.4;\r\n width: 400px;\r\n position: relative;\r\n}\r\n\r\n.truncate-text-multiline:after {\r\n content: '';\r\n position: absolute;\r\n bottom: 0;\r\n right: 0;\r\n width: 150px;\r\n height: 36.4px;\r\n background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%);\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"truncate-text-multiline\"] .truncate-text-multiline {\n overflow: hidden;\n display: block;\n height: 109.2px;\n margin: 0 auto;\n font-size: 26px;\n line-height: 1.4;\n width: 400px;\n position: relative; }\n\n[data-scope=\"truncate-text-multiline\"] .truncate-text-multiline:after {\n content: '';\n position: absolute;\n bottom: 0;\n right: 0;\n width: 150px;\n height: 36.4px;\n background: linear-gradient(to right, rgba(0, 0, 0, 0), #f5f6f9 50%); }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "487720c3bf69c29c26cd0033d69f7391b634c4d9bf0e72a1da29957b945a9cbf"
+ }
+ },
+ {
+ "id": "truncate-text",
+ "title": "Truncate text",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "truncate-text.md",
+ "text": "If the text is longer than one line, it will be truncated and end with an ellipsis `…`.\n\n",
+ "explanation": "\n\n1. `overflow: hidden` prevents the text from overflowing its dimensions\n (for a block, 100% width and auto height).\n2. `white-space: nowrap` prevents the text from exceeding one line in height.\n3. `text-overflow: ellipsis` makes it so that if the text exceeds its dimensions, it\n will end with an ellipsis.\n4. `width: 200px;` ensures the element has a dimension, to know when to get ellipsis\n\n",
+ "browserSupport": {
+ "text": "\n\n⚠️ Only works for single line elements. \n\n- https://caniuse.com/#feat=text-overflow\n\n\n\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "If I exceed one line's width, I will be truncated.
",
+ "css": ".truncate-text {\r\n overflow: hidden;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n width: 200px;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"truncate-text\"] .truncate-text {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n width: 200px; }\n"
+ },
+ "tags": [
+ "layout",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "db78085f4583d992126b4ceb74cc680300aa67c16d37b68d55c140fe453840d3"
+ }
+ },
+ {
+ "id": "zebra-striped-list",
+ "title": "Zebra striped list",
+ "type": "snippet",
+ "attributes": {
+ "fileName": "zebra-striped-list.md",
+ "text": "Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row.\n\n",
+ "explanation": "\n\n1. 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.\n\nNote that you can use it to apply different styles to other HTML elements like div, tr, p, ol, etc.\n\n",
+ "browserSupport": {
+ "text": "\n\nhttps://caniuse.com/#feat=css-sel3\n",
+ "supportPercentage": 100
+ },
+ "codeBlocks": {
+ "html": "\r\n Item 01 \r\n Item 02 \r\n Item 03 \r\n Item 04 \r\n Item 05 \r\n ",
+ "css": "li:nth-child(odd) {\r\n background-color: #ddd;\r\n}",
+ "js": "",
+ "scopedCss": "[data-scope=\"zebra-striped-list\"] li:nth-child(odd) {\n background-color: #ddd; }\n"
+ },
+ "tags": [
+ "visual",
+ "intermediate"
+ ]
+ },
+ "meta": {
+ "hash": "2c11f668918ede13c492719a76a5b89173aa4e72ad896cd2d7e45bed9671a2f0"
+ }
+ }
+ ],
+ "meta": {
+ "specification": "http://jsonapi.org/format/",
+ "type": "snippetArray"
+ }
+}
\ No newline at end of file
diff --git a/snippets/bouncing-loader.md b/snippets/bouncing-loader.md
index 91ded94f7..0c4234c0f 100644
--- a/snippets/bouncing-loader.md
+++ b/snippets/bouncing-loader.md
@@ -5,8 +5,6 @@ tags: animation,intermediate
Creates a bouncing loader animation.
-#### HTML
-
```html
@@ -15,8 +13,6 @@ Creates a bouncing loader animation.
```
-#### CSS
-
```css
@keyframes bouncing-loader {
to {
@@ -44,8 +40,6 @@ Creates a bouncing loader animation.
}
```
-#### Demo
-
#### Explanation
Note: `1rem` is usually `16px`.
diff --git a/snippets/box-sizing-reset.md b/snippets/box-sizing-reset.md
index 2426ae314..2460e20cd 100644
--- a/snippets/box-sizing-reset.md
+++ b/snippets/box-sizing-reset.md
@@ -5,15 +5,11 @@ tags: layout,intermediate
Resets the box-model so that `width`s and `height`s are not affected by their `border`s or `padding`.
-#### HTML
-
```html
border-box
content-box
```
-#### CSS
-
```css
html {
box-sizing: border-box;
@@ -37,8 +33,6 @@ html {
}
```
-#### Demo
-
#### Explanation
1. `box-sizing: border-box` makes the addition of `padding` or `border`s not affect an element's `width` or `height`.
diff --git a/snippets/button-border-animation.md b/snippets/button-border-animation.md
index b7a633bb2..46ce61339 100644
--- a/snippets/button-border-animation.md
+++ b/snippets/button-border-animation.md
@@ -5,14 +5,10 @@ tags: animation,intermediate
Creates a border animation on hover.
-#### HTML
-
```html
Submit
```
-#### CSS
-
```css
.button {
background-color: #c47135;
@@ -51,14 +47,8 @@ Creates a border animation on hover.
}
```
-#### Demo
-
#### Explanation
Use the `:before` and `:after` pseduo-elements as borders that animate on hover.
#### Browser support
-
-
-
-
diff --git a/snippets/calc.md b/snippets/calc.md
index 5c6af10ac..65744d3f8 100644
--- a/snippets/calc.md
+++ b/snippets/calc.md
@@ -5,14 +5,12 @@ tags: other,intermediate
The function calc() allows to define CSS values with the use of mathematical expressions, the value adopted for the property is the result of a mathematical expression.
-#### HTML
+
```html
```
-#### CSS
-
```css
.box-example {
height: 280px;
@@ -21,7 +19,7 @@ The function calc() allows to define CSS values with the use of mathematical exp
}
```
-#### Demo
+
If you want to align a background-image from right and bottom wasn't possible with just straight length values.
So now it's possible using calc():
diff --git a/snippets/circle.md b/snippets/circle.md
index 33c189bfa..72ffbf8f8 100644
--- a/snippets/circle.md
+++ b/snippets/circle.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Creates a circle shape with pure CSS.
-#### HTML
-
```html
```
-#### CSS
-
```css
.circle {
border-radius: 50%;
@@ -22,8 +18,6 @@ Creates a circle shape with pure CSS.
}
```
-#### Demo
-
#### Explanation
`border-radius: 50%` curves the borders of an element to create a circle.
diff --git a/snippets/clearfix.md b/snippets/clearfix.md
index 058ca5cc6..3d1db7748 100644
--- a/snippets/clearfix.md
+++ b/snippets/clearfix.md
@@ -7,8 +7,6 @@ Ensures that an element self-clears its children.
###### Note: This is only useful if you are still using float to build layouts. Please consider using a modern approach with flexbox layout or grid layout.
-#### HTML
-
```html
float a
@@ -17,8 +15,6 @@ Ensures that an element self-clears its children.
```
-#### CSS
-
```css
.clearfix::after {
content: '';
@@ -31,8 +27,6 @@ Ensures that an element self-clears its children.
}
```
-#### Demo
-
#### Explanation
1. `.clearfix::after` defines a pseudo-element.
diff --git a/snippets/constant-width-to-height-ratio.md b/snippets/constant-width-to-height-ratio.md
index 5baa17292..974e5917c 100644
--- a/snippets/constant-width-to-height-ratio.md
+++ b/snippets/constant-width-to-height-ratio.md
@@ -6,14 +6,10 @@ tags: layout,intermediate
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
-
```html
```
-#### CSS
-
```css
.constant-width-to-height-ratio {
background: #333;
@@ -31,8 +27,6 @@ Given an element of variable width, it will ensure its height remains proportion
}
```
-#### Demo
-
#### Explanation
`padding-top` on the `::before` pseudo-element causes the height of the element to equal a percentage of
diff --git a/snippets/counter.md b/snippets/counter.md
index 47ccc2d43..528296a28 100644
--- a/snippets/counter.md
+++ b/snippets/counter.md
@@ -5,8 +5,6 @@ tags: visual, other,intermediate
Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.
-#### HTML
-
```html
List item
@@ -22,8 +20,6 @@ Counters are, in essence, variables maintained by CSS whose values may be increm
```
-#### CSS
-
```css
ul {
counter-reset: counter;
@@ -35,8 +31,6 @@ li::before {
}
```
-#### Demo
-
#### Explanation
You can create a ordered list using any type of HTML.
diff --git a/snippets/custom-scrollbar.md b/snippets/custom-scrollbar.md
index 17d66b58a..e2dfeb9b9 100644
--- a/snippets/custom-scrollbar.md
+++ b/snippets/custom-scrollbar.md
@@ -5,7 +5,7 @@ tags: visual,intermediate
Customizes the scrollbar style for the document and elements with scrollable overflow, on WebKit platforms.
-#### HTML
+
```html
@@ -18,7 +18,7 @@ Customizes the scrollbar style for the document and elements with scrollable ove
```
-#### CSS
+
```css
.custom-scrollbar {
@@ -43,7 +43,7 @@ Customizes the scrollbar style for the document and elements with scrollable ove
}
```
-#### Demo
+
#### Explanation
diff --git a/snippets/custom-text-selection.md b/snippets/custom-text-selection.md
index a7937a616..f26e40507 100644
--- a/snippets/custom-text-selection.md
+++ b/snippets/custom-text-selection.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Changes the styling of text selection.
-#### HTML
-
```html
Select some of this text.
```
-#### CSS
-
```css
::selection {
background: aquamarine;
@@ -24,8 +20,6 @@ Changes the styling of text selection.
}
```
-#### Demo
-
#### Explanation
`::selection` defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element.
diff --git a/snippets/custom-variables.md b/snippets/custom-variables.md
index 33ac5b8cb..923970d34 100644
--- a/snippets/custom-variables.md
+++ b/snippets/custom-variables.md
@@ -5,14 +5,10 @@ tags: other,intermediate
CSS variables that contain specific values to be reused throughout a document.
-#### HTML
-
```html
CSS is awesome!
```
-#### CSS
-
```css
:root {
/* Place variables within here to use the variables globally. */
@@ -30,8 +26,6 @@ CSS variables that contain specific values to be reused throughout a document.
}
```
-#### Demo
-
#### Explanation
The variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document. Variables can also be scoped to a selector if defined within the block.
diff --git a/snippets/disable-selection.md b/snippets/disable-selection.md
index b0aac7ef7..84e532f9c 100644
--- a/snippets/disable-selection.md
+++ b/snippets/disable-selection.md
@@ -5,23 +5,17 @@ tags: interactivity,intermediate
Makes the content unselectable.
-#### HTML
-
```html
You can select me.
You can't select me!
```
-#### CSS
-
```css
.unselectable {
user-select: none;
}
```
-#### Demo
-
#### Explanation
`user-select: none` specifies that the text cannot be selected.
diff --git a/snippets/display-table-centering.md b/snippets/display-table-centering.md
index a45b48df8..7586a9574 100644
--- a/snippets/display-table-centering.md
+++ b/snippets/display-table-centering.md
@@ -5,16 +5,12 @@ tags: layout,intermediate
Vertically and horizontally centers a child element within its parent element using `display: table` (as an alternative to `flexbox`).
-#### HTML
-
```html
```
-#### CSS
-
```css
.container {
border: 1px solid #333;
@@ -35,8 +31,6 @@ Vertically and horizontally centers a child element within its parent element us
}
```
-#### Demo
-
#### Explanation
1. `display: table` on '.center' allows the element to behave like a `` HTML element.
diff --git a/snippets/donut-spinner.md b/snippets/donut-spinner.md
index 9e1dcd8e4..4472e72e9 100644
--- a/snippets/donut-spinner.md
+++ b/snippets/donut-spinner.md
@@ -5,14 +5,10 @@ tags: animation,intermediate
Creates a donut spinner that can be used to indicate the loading of content.
-#### HTML
-
```html
```
-#### CSS
-
```css
@keyframes donut-spin {
0% {
@@ -33,8 +29,6 @@ Creates a donut spinner that can be used to indicate the loading of content.
}
```
-#### Demo
-
#### Explanation
Use a semi-transparent `border` for the whole element, except one side that will
diff --git a/snippets/dynamic-shadow.md b/snippets/dynamic-shadow.md
index db34c1a41..444bc9fda 100644
--- a/snippets/dynamic-shadow.md
+++ b/snippets/dynamic-shadow.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Creates a shadow similar to `box-shadow` but based on the colors of the element itself.
-#### HTML
-
```html
```
-#### CSS
-
```css
.dynamic-shadow {
position: relative;
@@ -34,8 +30,6 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element
}
```
-#### Demo
-
#### Explanation
1. `position: relative` on the element establishes a Cartesian positioning context for psuedo-elements.
diff --git a/snippets/easing-variables.md b/snippets/easing-variables.md
index bcded771b..a76f6b042 100644
--- a/snippets/easing-variables.md
+++ b/snippets/easing-variables.md
@@ -6,14 +6,10 @@ tags: animation,intermediate
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
-
```html
Hover
```
-#### CSS
-
```css
:root {
/* Place variables in here to use globally */
@@ -56,8 +52,6 @@ powerful than the built-in `ease`, `ease-in`, `ease-out` and `ease-in-out`.
}
```
-#### Demo
-
#### Explanation
The variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document. In HTML, `:root` represents the `` element and is identical to the selector `html`, except that its specificity is higher.
diff --git a/snippets/etched-text.md b/snippets/etched-text.md
index 97af72f28..d346eac0f 100644
--- a/snippets/etched-text.md
+++ b/snippets/etched-text.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Creates an effect where text appears to be "etched" or engraved into the background.
-#### HTML
-
```html
I appear etched into the background.
```
-#### CSS
-
```css
.etched-text {
text-shadow: 0 2px white;
@@ -22,8 +18,6 @@ Creates an effect where text appears to be "etched" or engraved into the backgro
}
```
-#### Demo
-
#### Explanation
`text-shadow: 0 2px white` creates a white shadow offset `0px` horizontally and `2px` vertically
diff --git a/snippets/evenly-distributed-children.md b/snippets/evenly-distributed-children.md
index 6f33e7ca9..067cdd8b2 100644
--- a/snippets/evenly-distributed-children.md
+++ b/snippets/evenly-distributed-children.md
@@ -5,8 +5,6 @@ tags: layout,intermediate
Evenly distributes child elements within a parent element.
-#### HTML
-
```html
Item1
@@ -15,8 +13,6 @@ Evenly distributes child elements within a parent element.
```
-#### CSS
-
```css
.evenly-distributed-children {
display: flex;
@@ -24,8 +20,6 @@ Evenly distributes child elements within a parent element.
}
```
-#### Demo
-
#### Explanation
1. `display: flex` enables flexbox.
diff --git a/snippets/fit-image-in-container.md b/snippets/fit-image-in-container.md
index 77909f972..0ce9d4d3b 100644
--- a/snippets/fit-image-in-container.md
+++ b/snippets/fit-image-in-container.md
@@ -5,15 +5,11 @@ tags: layout, visual,intermediate
Changes the fit and position of an image within its container while preserving its aspect ratio. Previously only possible using a background image and the `background-size` property.
-#### HTML
-
```html
```
-#### CSS
-
```css
.image {
background: #34495e;
@@ -33,8 +29,6 @@ Changes the fit and position of an image within its container while preserving i
}
```
-#### Demo
-
#### Explanation
- `object-fit: contain` fits the entire image within the container while preserving its aspect ratio.
@@ -44,7 +38,3 @@ Changes the fit and position of an image within its container while preserving i
#### Browser support
- https://caniuse.com/#feat=object-fit
-
-
-
-
diff --git a/snippets/flexbox-centering.md b/snippets/flexbox-centering.md
index 44f674494..7b72e1c4d 100644
--- a/snippets/flexbox-centering.md
+++ b/snippets/flexbox-centering.md
@@ -5,14 +5,10 @@ tags: layout,intermediate
Horizontally and vertically centers a child element within a parent element using `flexbox`.
-#### HTML
-
```html
```
-#### CSS
-
```css
.flexbox-centering {
display: flex;
@@ -22,8 +18,6 @@ Horizontally and vertically centers a child element within a parent element usin
}
```
-#### Demo
-
#### Explanation
1. `display: flex` enables flexbox.
diff --git a/snippets/focus-within.md b/snippets/focus-within.md
index 87ff62a6a..f92b2bf85 100644
--- a/snippets/focus-within.md
+++ b/snippets/focus-within.md
@@ -5,8 +5,6 @@ tags: visual, interactivity,intermediate
Changes the appearance of a form if any of its children are focused.
-#### HTML
-
```html
```
-#### CSS
-
```css
form {
border: 3px solid #2d98da;
@@ -31,8 +27,6 @@ form:focus-within {
}
```
-#### Demo
-
#### Explanation
diff --git a/snippets/fullscreen.md b/snippets/fullscreen.md
index 7d92af517..37ace461b 100644
--- a/snippets/fullscreen.md
+++ b/snippets/fullscreen.md
@@ -5,8 +5,6 @@ tags: visual,intermediate
The :fullscreen CSS pseudo-class represents an element that's displayed when the browser is in fullscreen mode.
-#### HTML
-
```html
Click the button below to enter the element into fullscreen mode.
@@ -18,8 +16,6 @@ The :fullscreen CSS pseudo-class represents an element that's displayed when the
```
-#### CSS
-
```css
.container {
margin: 40px auto;
@@ -50,8 +46,6 @@ The :fullscreen CSS pseudo-class represents an element that's displayed when the
}
```
-#### Demo
-
#### Explanation
1. `fullscreen` CSS pseudo-class selector is used to select and style an element that is being displayed in fullscreen mode.
diff --git a/snippets/ghost-trick.md b/snippets/ghost-trick.md
index f3b502ba5..2227a75c6 100644
--- a/snippets/ghost-trick.md
+++ b/snippets/ghost-trick.md
@@ -5,16 +5,12 @@ tags: layout,intermediate
Vertically centers an element in another.
-#### HTML
-
```html
Vertically centered without changing the position property.
```
-#### CSS
-
```css
.ghosting {
height: 300px;
@@ -34,8 +30,6 @@ p {
}
```
-#### Demo
-
#### Explanation
Use the style of a `:before` pseudo-element to vertically align inline elements without changing their `position` property.
diff --git a/snippets/gradient-text.md b/snippets/gradient-text.md
index 87564fc3a..2338a7d0b 100644
--- a/snippets/gradient-text.md
+++ b/snippets/gradient-text.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Gives text a gradient color.
-#### HTML
-
```html
Gradient text
```
-#### CSS
-
```css
.gradient-text {
background: -webkit-linear-gradient(pink, red);
@@ -21,8 +17,6 @@ Gives text a gradient color.
}
```
-#### Demo
-
#### Explanation
1. `background: -webkit-linear-gradient(...)` gives the text element a gradient background.
diff --git a/snippets/grid-centering.md b/snippets/grid-centering.md
index 0ad17ed23..c7cfadb42 100644
--- a/snippets/grid-centering.md
+++ b/snippets/grid-centering.md
@@ -5,14 +5,10 @@ tags: layout,intermediate
Horizontally and vertically centers a child element within a parent element using `grid`.
-#### HTML
-
```html
```
-#### CSS
-
```css
.grid-centering {
display: grid;
@@ -22,8 +18,6 @@ Horizontally and vertically centers a child element within a parent element usin
}
```
-#### Demo
-
#### Explanation
1. `display: grid` enables grid.
diff --git a/snippets/hairline-border.md b/snippets/hairline-border.md
index fd7ecc035..c8ffd0694 100644
--- a/snippets/hairline-border.md
+++ b/snippets/hairline-border.md
@@ -6,14 +6,10 @@ tags: visual,intermediate
Gives an element a border equal to 1 native device pixel in width, which can look
very sharp and crisp.
-#### HTML
-
```html
text
```
-#### CSS
-
```css
.hairline-border {
box-shadow: 0 0 0 1px;
@@ -38,8 +34,6 @@ very sharp and crisp.
}
```
-#### Demo
-
#### Explanation
1. `box-shadow`, when only using spread, adds a pseudo-border which can use subpixels\*.
diff --git a/snippets/height-transition.md b/snippets/height-transition.md
index 624c99540..f587234b7 100644
--- a/snippets/height-transition.md
+++ b/snippets/height-transition.md
@@ -5,8 +5,6 @@ tags: animation,intermediate
Transitions an element's height from `0` to `auto` when its height is unknown.
-#### HTML
-
```html
Hover me to see a height transition.
@@ -14,8 +12,6 @@ Transitions an element's height from `0` to `auto` when its height is unknown.
```
-#### CSS
-
```css
.el {
transition: max-height 0.5s;
@@ -28,28 +24,20 @@ Transitions an element's height from `0` to `auto` when its height is unknown.
}
```
-#### JavaScript
-
```js
var el = document.querySelector('.el')
var height = el.scrollHeight
el.style.setProperty('--max-height', height + 'px')
```
-#### Demo
-
#### Explanation
-##### CSS
-
1. `transition: max-height: 0.5s cubic-bezier(...)` specifies that changes to `max-height` should be transitioned over 0.5 seconds, using an `ease-out-quint` timing function.
2. `overflow: hidden` prevents the contents of the hidden element from overflowing its container.
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.
-
-##### 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.
diff --git a/snippets/hover-shadow-box-animation.md b/snippets/hover-shadow-box-animation.md
index a68f737b7..772c4691b 100644
--- a/snippets/hover-shadow-box-animation.md
+++ b/snippets/hover-shadow-box-animation.md
@@ -5,14 +5,10 @@ tags: animation,intermediate
Creates a shadow box around the text when it is hovered.
-#### HTML
-
```html
Box it!
```
-#### CSS
-
```css
.hover-shadow-box-animation {
display: inline-block;
@@ -31,8 +27,6 @@ Creates a shadow box around the text when it is hovered.
}
```
-#### Demo
-
#### Explanation
1. `display: inline-block` to set width and length for `p` element thus making it an `inline-block`.
diff --git a/snippets/hover-underline-animation.md b/snippets/hover-underline-animation.md
index cb7480a0a..1c813105b 100644
--- a/snippets/hover-underline-animation.md
+++ b/snippets/hover-underline-animation.md
@@ -7,14 +7,10 @@ Creates an animated underline effect when the text is hovered over.
**Credit:** https://flatuicolors.com/
-#### HTML
-
```html
Hover this text to see the effect!
```
-#### CSS
-
```css
.hover-underline-animation {
display: inline-block;
@@ -39,8 +35,6 @@ Creates an animated underline effect when the text is hovered over.
}
```
-#### Demo
-
#### Explanation
1. `display: inline-block` makes the block `p` an `inline-block` to prevent the underline from
diff --git a/snippets/last-item-with-remaining-available-height.md b/snippets/last-item-with-remaining-available-height.md
index cc77aded3..7cb30b1b6 100644
--- a/snippets/last-item-with-remaining-available-height.md
+++ b/snippets/last-item-with-remaining-available-height.md
@@ -5,8 +5,6 @@ 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.
-#### HTML
-
```html
Div 1
@@ -15,8 +13,6 @@ Take advantage of available viewport space by giving the last element the remain
```
-#### CSS
-
```css
html,
body {
@@ -36,8 +32,6 @@ body {
}
```
-#### Demo
-
#### Explanation
1. `height: 100%` set the height of container as viewport height.
@@ -52,7 +46,3 @@ The parent must have a viewport height. `flex-grow: 1` could be applied to the f
⚠️ Needs prefixes for full support.
- https://caniuse.com/#feat=flexbox
-
-
-
-
diff --git a/snippets/mouse-cursor-gradient-tracking.md b/snippets/mouse-cursor-gradient-tracking.md
index 81688b536..32730777f 100644
--- a/snippets/mouse-cursor-gradient-tracking.md
+++ b/snippets/mouse-cursor-gradient-tracking.md
@@ -7,14 +7,10 @@ A hover effect where the gradient follows the mouse cursor.
**Credit:** [Tobias Reich](https://codepen.io/electerious/pen/MQrRxX)
-#### HTML
-
```html
Hover me
```
-#### CSS
-
```css
.mouse-cursor-gradient-tracking {
position: relative;
@@ -50,8 +46,6 @@ A hover effect where the gradient follows the mouse cursor.
}
```
-#### JavaScript
-
```js
var btn = document.querySelector('.mouse-cursor-gradient-tracking')
btn.onmousemove = function(e) {
@@ -62,11 +56,11 @@ btn.onmousemove = function(e) {
}
```
-#### Demo
-
#### Explanation
-_TODO_
+1. `--x` and `--y` are used to track the position of the mouse on the button.
+2. `--size` is used to keep modify of the gradient's dimensions.
+3. `background: radial-gradient(circle closest-side, pink, transparent);` creates the gradient at the correct postion.
#### Browser support
diff --git a/snippets/not-selector.md b/snippets/not-selector.md
index 0e515d9cb..5012318b6 100644
--- a/snippets/not-selector.md
+++ b/snippets/not-selector.md
@@ -5,8 +5,6 @@ tags: visual,intermediate
The `:not` psuedo selector is useful for styling a group of elements, while leaving the last (or specified) element unstyled.
-#### HTML
-
```html
One
@@ -16,8 +14,6 @@ The `:not` psuedo selector is useful for styling a group of elements, while leav
```
-#### CSS
-
```css
.css-not-selector-shortcut {
display: flex;
@@ -38,8 +34,6 @@ li:not(:last-child) {
}
```
-#### Demo
-
#### Explanation
`li:not(:last-child)` specifies that the styles should apply to all `li` elements except
diff --git a/snippets/offscreen.md b/snippets/offscreen.md
index 4c1bfcd52..e397d3a69 100644
--- a/snippets/offscreen.md
+++ b/snippets/offscreen.md
@@ -5,16 +5,12 @@ 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.
-#### HTML
-
```html
Learn More about pants
```
-#### CSS
-
```css
.offscreen {
border: 0;
@@ -28,8 +24,6 @@ A bulletproof way to completely hide an element visually and positionally in the
}
```
-#### Demo
-
#### Explanation
1. Remove all borders.
diff --git a/snippets/overflow-scroll-gradient.md b/snippets/overflow-scroll-gradient.md
index debaf5de1..e5b6fa1a2 100644
--- a/snippets/overflow-scroll-gradient.md
+++ b/snippets/overflow-scroll-gradient.md
@@ -5,8 +5,6 @@ tags: visual,intermediate
Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled.
-#### HTML
-
```html
@@ -22,8 +20,6 @@ Adds a fading gradient to an overflowing element to better indicate there is mor
```
-#### CSS
-
```css
.overflow-scroll-gradient {
position: relative;
@@ -50,8 +46,6 @@ Adds a fading gradient to an overflowing element to better indicate there is mor
}
```
-#### Demo
-
#### Explanation
1. `position: relative` on the parent establishes a Cartesian positioning context for pseudo-elements.
diff --git a/snippets/popout-menu.md b/snippets/popout-menu.md
index 79b138763..f4e0a85b3 100644
--- a/snippets/popout-menu.md
+++ b/snippets/popout-menu.md
@@ -5,14 +5,10 @@ tags: interactivity,intermediate
Reveals an interactive popout menu on hover and focus.
-#### HTML
-
```html
```
-#### CSS
-
```css
.reference {
position: relative;
@@ -35,8 +31,6 @@ Reveals an interactive popout menu on hover and focus.
}
```
-#### Demo
-
#### Explanation
1. `position: relative` on the reference parent establishes a Cartesian positioning context for its child.
diff --git a/snippets/pretty-text-underline.md b/snippets/pretty-text-underline.md
index 868af7203..2f01deef3 100644
--- a/snippets/pretty-text-underline.md
+++ b/snippets/pretty-text-underline.md
@@ -6,14 +6,10 @@ tags: visual,intermediate
A nicer alternative to `text-decoration: underline` or `
` where descenders do not clip the underline.
Natively implemented as `text-decoration-skip-ink: auto` but it has less control over the underline.
-#### HTML
-
```html
Pretty text underline without clipping descending letters.
```
-#### CSS
-
```css
.pretty-text-underline {
display: inline;
@@ -33,8 +29,6 @@ Natively implemented as `text-decoration-skip-ink: auto` but it has less control
}
```
-#### Demo
-
#### Explanation
1. `text-shadow` uses 4 values with offsets that cover a 4x4 px area to ensure the underline
diff --git a/snippets/reset-all-styles.md b/snippets/reset-all-styles.md
index 787d96670..83a0c3acc 100644
--- a/snippets/reset-all-styles.md
+++ b/snippets/reset-all-styles.md
@@ -5,8 +5,6 @@ tags: visual,intermediate
Resets all styles to default values with one property. This will not affect `direction` and `unicode-bidi` properties.
-#### HTML
-
```html
Title
@@ -18,16 +16,12 @@ Resets all styles to default values with one property. This will not affect `dir
```
-#### CSS
-
```css
.reset-all-styles {
all: initial;
}
```
-#### Demo
-
#### Explanation
The `all` property allows you to reset all styles (inherited or not) to default values.
diff --git a/snippets/shape-separator.md b/snippets/shape-separator.md
index 417cae338..64a2b53b3 100644
--- a/snippets/shape-separator.md
+++ b/snippets/shape-separator.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Uses an SVG shape to separate two different blocks to create more a interesting visual appearance compared to standard horizontal separation.
-#### HTML
-
```html
```
-#### CSS
-
```css
.shape-separator {
position: relative;
@@ -29,8 +25,6 @@ Uses an SVG shape to separate two different blocks to create more a interesting
}
```
-#### Demo
-
#### Explanation
1. `position: relative` on the element establishes a Cartesian positioning context for pseudo elements.
diff --git a/snippets/sibling-fade.md b/snippets/sibling-fade.md
index 5f32604f9..3ab979f01 100644
--- a/snippets/sibling-fade.md
+++ b/snippets/sibling-fade.md
@@ -5,8 +5,6 @@ tags: interactivity,intermediate
Fades out the siblings of a hovered item.
-#### HTML
-
```html
Item 1 Item 2 Item 3 Item 4
@@ -14,8 +12,6 @@ Fades out the siblings of a hovered item.
```
-#### CSS
-
```css
span {
padding: 0 1rem;
@@ -27,8 +23,6 @@ span {
}
```
-#### Demo
-
#### Explanation
1. `transition: opacity 0.2s` specifies that changes to opacity will be transitioned over 0.2 seconds.
diff --git a/snippets/system-font-stack.md b/snippets/system-font-stack.md
index 453948d9b..030b91359 100644
--- a/snippets/system-font-stack.md
+++ b/snippets/system-font-stack.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Uses the native font of the operating system to get close to a native app feel.
-#### HTML
-
```html
This text uses the system font.
```
-#### CSS
-
```css
.system-font-stack {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu,
@@ -20,8 +16,6 @@ Uses the native font of the operating system to get close to a native app feel.
}
```
-#### Demo
-
#### Explanation
The browser looks for each successive font, preferring the first one if possible, and
diff --git a/snippets/toggle-switch.md b/snippets/toggle-switch.md
index aeaf5d646..a4075383c 100644
--- a/snippets/toggle-switch.md
+++ b/snippets/toggle-switch.md
@@ -5,14 +5,10 @@ tags: visual, interactivity,intermediate
Creates a toggle switch with CSS only.
-#### HTML
-
```html
```
-#### CSS
-
```css
.switch {
position: relative;
@@ -50,8 +46,6 @@ input[type='checkbox']:checked + .switch {
}
```
-#### Demo
-
#### Explanation
This effect is styling only the `
` element to look like a toggle switch, and hiding the actual ` ` checkbox by positioning it offscreen. When clicking the label associated with the ` ` element, it sets the ` ` checkbox into the `:checked` state.
@@ -69,7 +63,3 @@ This effect is styling only the `` element to look like a toggle switch,
⚠️ Requires prefixes for full support.
- https://caniuse.com/#feat=transforms2d
-
-
-
-
diff --git a/snippets/transform-centering.md b/snippets/transform-centering.md
index 3227f1905..8ae8d36c9 100644
--- a/snippets/transform-centering.md
+++ b/snippets/transform-centering.md
@@ -5,14 +5,10 @@ tags: layout,intermediate
Vertically and horizontally centers a child element within its parent element using `position: absolute` and `transform: translate()` (as an alternative to `flexbox` or `display: table`). Similar to `flexbox`, this method does not require you to know the height or width of your parent or child so it is ideal for responsive applications.
-#### HTML
-
```html
```
-#### CSS
-
```css
.parent {
border: 1px solid #333;
@@ -30,8 +26,6 @@ Vertically and horizontally centers a child element within its parent element us
}
```
-#### Demo
-
#### Explanation
1. `position: absolute` on the child element allows it to be positioned based on its containing block.
diff --git a/snippets/triangle.md b/snippets/triangle.md
index d426697ee..256043d3b 100644
--- a/snippets/triangle.md
+++ b/snippets/triangle.md
@@ -5,14 +5,10 @@ tags: visual,intermediate
Creates a triangle shape with pure CSS.
-#### HTML
-
```html
```
-#### CSS
-
```css
.triangle {
width: 0;
@@ -23,8 +19,6 @@ Creates a triangle shape with pure CSS.
}
```
-#### Demo
-
#### Explanation
[View this link for a detailed explanation.](https://stackoverflow.com/q/7073484)
diff --git a/snippets/truncate-text-multiline.md b/snippets/truncate-text-multiline.md
index 48b5730fd..7e42b3caa 100644
--- a/snippets/truncate-text-multiline.md
+++ b/snippets/truncate-text-multiline.md
@@ -5,8 +5,6 @@ tags: layout,intermediate
If the text is longer than one line, it will be truncated for `n` lines and end with an gradient fade.
-#### HTML
-
```html
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
@@ -14,8 +12,6 @@ If the text is longer than one line, it will be truncated for `n` lines and end
```
-#### CSS
-
```css
.truncate-text-multiline {
overflow: hidden;
@@ -39,8 +35,6 @@ If the text is longer than one line, it will be truncated for `n` lines and end
}
```
-#### Demo
-
#### Explanation
1. `overflow: hidden` prevents the text from overflowing its dimensions
diff --git a/snippets/truncate-text.md b/snippets/truncate-text.md
index 9d3e089cf..347454174 100644
--- a/snippets/truncate-text.md
+++ b/snippets/truncate-text.md
@@ -5,14 +5,10 @@ tags: layout,intermediate
If the text is longer than one line, it will be truncated and end with an ellipsis `…`.
-#### HTML
-
```html
If I exceed one line's width, I will be truncated.
```
-#### CSS
-
```css
.truncate-text {
overflow: hidden;
@@ -22,8 +18,6 @@ If the text is longer than one line, it will be truncated and end with an ellips
}
```
-#### Demo
-
#### Explanation
1. `overflow: hidden` prevents the text from overflowing its dimensions
diff --git a/snippets/zebra-striped-list.md b/snippets/zebra-striped-list.md
index 7514ea00b..92cf0464a 100644
--- a/snippets/zebra-striped-list.md
+++ b/snippets/zebra-striped-list.md
@@ -5,8 +5,6 @@ tags: visual,intermediate
Creates a striped list with alternating background colors, which is useful for differentiating siblings that have content spread across a wide row.
-#### HTML
-
```html
Item 01
@@ -17,16 +15,12 @@ Creates a striped list with alternating background colors, which is useful for d
```
-#### CSS
-
```css
li:nth-child(odd) {
background-color: #ddd;
}
```
-#### Demo
-
#### Explanation
1. 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.
@@ -36,7 +30,3 @@ Note that you can use it to apply different styles to other HTML elements like d
#### Browser support
https://caniuse.com/#feat=css-sel3
-
-
-
-
diff --git a/src/css/components/back-to-top-button.scss b/src/css/components/back-to-top-button.scss
deleted file mode 100644
index 8cbeeb5a1..000000000
--- a/src/css/components/back-to-top-button.scss
+++ /dev/null
@@ -1,45 +0,0 @@
-.back-to-top-button {
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: pointer;
- font-weight: bold;
- background: white;
- width: 4rem;
- height: 4rem;
- position: fixed;
- right: 2rem;
- bottom: 2rem;
- border-radius: 50%;
- user-select: none;
- box-shadow: 0 0.4rem 0.8rem -0.1rem rgba(0, 32, 128, 0.15);
- transition: all 0.2s ease-out;
- visibility: hidden;
- opacity: 0;
- z-index: 1;
- border: 1px solid rgba(0, 32, 128, 0.1);
- outline: 0;
- color: inherit;
-
- &:hover,
- &:focus {
- transform: scale(1.1);
- box-shadow: 0 0.8rem 1.6rem -0.2rem rgba(0, 32, 128, 0.15);
- color: #35a8ff;
- }
-
- &:focus {
- box-shadow: 0 0.8rem 1.6rem -0.2rem rgba(0, 32, 128, 0.15), 0 0 2px 2px #35a8ff;
- outline-style: none;
- }
-
- &.is-visible {
- visibility: visible;
- opacity: 1;
- }
-
- .feather {
- width: 2rem;
- height: 2rem;
- }
-}
diff --git a/src/css/components/base.scss b/src/css/components/base.scss
deleted file mode 100644
index 2e057d544..000000000
--- a/src/css/components/base.scss
+++ /dev/null
@@ -1,73 +0,0 @@
-html {
- font-size: 0.95rem;
- box-sizing: border-box;
-}
-
-*,
-*::after,
-*::before {
- box-sizing: inherit;
-}
-
-body {
- font-family: -apple-system, BlinkMacSystemFont, Roboto, Segoe UI, 'Helvetica Neue', Helvetica,
- Arial, sans-serif;
- background: #f2f3f8;
- color: rgb(50, 75, 100);
- line-height: 1.5;
-}
-
-a {
- color: #157bda;
- text-decoration: none;
- word-wrap: break-word;
- overflow-wrap: break-word;
-
- &:hover {
- color: #0090ff;
- }
-}
-
-hr {
- border: 0;
- border-top: 1px solid rgba(0, 32, 128, 0.1);
-}
-
-ul,
-ol {
- padding-left: 1.25rem;
-}
-
-.container {
- max-width: 64rem;
- padding: 0 2%;
- margin: 0 auto;
-}
-
-.main > .container {
- padding: 0;
-}
-
-@media (min-width: 579px) {
- .main > .container {
- padding: 0 2%;
- }
-}
-
-@media (min-width: 768px) {
- html {
- font-size: 1rem;
- }
-}
-
-@media (min-width: 992px) {
- .content-wrapper {
- margin-left: 20%;
- }
-}
-
-@media (min-width: 1400px) {
- .content-wrapper {
- margin-left: 275px;
- }
-}
diff --git a/src/css/components/buttons.scss b/src/css/components/buttons.scss
deleted file mode 100644
index 97e65aacc..000000000
--- a/src/css/components/buttons.scss
+++ /dev/null
@@ -1,76 +0,0 @@
-.btn {
- display: inline-block;
- position: relative;
- top: -1px;
- font-weight: bold;
- font-size: 0.75rem;
- text-transform: uppercase;
- color: #8385aa;
- white-space: nowrap;
- border: 1px solid #c8cbf2;
- border-radius: 2px;
- vertical-align: middle;
- line-height: 2;
- padding: 0 0.5rem;
- margin-right: 0.5rem;
- transition: all 0.1s ease-out;
- outline: 0;
-
- &.is-large {
- font-size: 0.95rem;
- border-radius: 0.2rem;
-
- .feather {
- top: -2px;
- width: 18px;
- height: 18px;
- }
- }
-
- .feather {
- vertical-align: middle;
- margin-right: 0.25rem;
- position: relative;
- top: -1px;
- width: 14px;
- height: 14px;
- }
-}
-
-button.btn {
- user-select: none;
- cursor: pointer;
- margin-bottom: 1rem;
- margin-right: 1rem;
- background: white;
-
- &:hover {
- background: #8385aa;
- border-color: #8385aa;
- color: white;
- }
-
- &.focus-visible:focus {
- box-shadow: 0 0 0 0.25rem transparentize(#8385aa, 0.5);
- }
-
- &:active {
- box-shadow: inset 0 0.1rem 0.1rem 0.1rem rgba(0, 0, 0, 0.2);
- background: darken(#8385aa, 10);
- border-color: darken(#8385aa, 10);
- }
-
- &.is-active {
- background: #7983ff;
- border-color: #7983ff;
- color: white;
-
- &.focus-visible:focus {
- box-shadow: 0 0 0 0.25rem transparentize(#7983ff, 0.5);
- }
- }
-
- &.codepen-btn {
- margin-top: 0.5rem;
- }
-}
diff --git a/src/css/components/hamburger.scss b/src/css/components/hamburger.scss
deleted file mode 100644
index e3357ce65..000000000
--- a/src/css/components/hamburger.scss
+++ /dev/null
@@ -1,927 +0,0 @@
-/*!
- * Hamburgers
- * @description Tasty CSS-animated hamburgers
- * @author Jonathan Suh @jonsuh
- * @site https://jonsuh.com/hamburgers
- * @link https://github.com/jonsuh/hamburgers
- */
-.hamburger {
- padding: 1rem;
- display: inline-block;
- cursor: pointer;
- transition-property: opacity, filter;
- transition-duration: 0.15s;
- transition-timing-function: linear;
- font: inherit;
- color: inherit;
- text-transform: none;
- background-color: transparent;
- border: 0;
- margin: 0;
- overflow: visible;
- outline: 0;
-}
-.hamburger:hover {
- opacity: 0.7;
-}
-
-.hamburger-box {
- width: 40px;
- height: 20px;
- display: inline-block;
- position: relative;
-}
-
-.hamburger-inner {
- display: block;
- top: 50%;
-}
-.hamburger-inner,
-.hamburger-inner::before,
-.hamburger-inner::after {
- width: 36px;
- height: 2px;
- background-color: #e3f5ff;
- border-radius: 4px;
- position: absolute;
- transition-property: transform;
- transition-duration: 0.15s;
- transition-timing-function: ease;
-}
-.hamburger-inner::before,
-.hamburger-inner::after {
- content: '';
- display: block;
-}
-.hamburger-inner::before {
- top: -10px;
-}
-.hamburger-inner::after {
- bottom: -10px;
-}
-
-/*
- * 3DX
- */
-.hamburger--3dx .hamburger-box {
- perspective: 80px;
-}
-
-.hamburger--3dx .hamburger-inner {
- transition: transform 0.15s cubic-bezier(0.645, 0.045, 0.355, 1),
- background-color 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-.hamburger--3dx .hamburger-inner::before,
-.hamburger--3dx .hamburger-inner::after {
- transition: transform 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hamburger--3dx.is-active .hamburger-inner {
- background-color: transparent;
- transform: rotateY(180deg);
-}
-.hamburger--3dx.is-active .hamburger-inner::before {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--3dx.is-active .hamburger-inner::after {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
-}
-
-/*
- * 3DX Reverse
- */
-.hamburger--3dx-r .hamburger-box {
- perspective: 80px;
-}
-
-.hamburger--3dx-r .hamburger-inner {
- transition: transform 0.15s cubic-bezier(0.645, 0.045, 0.355, 1),
- background-color 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-.hamburger--3dx-r .hamburger-inner::before,
-.hamburger--3dx-r .hamburger-inner::after {
- transition: transform 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hamburger--3dx-r.is-active .hamburger-inner {
- background-color: transparent;
- transform: rotateY(-180deg);
-}
-.hamburger--3dx-r.is-active .hamburger-inner::before {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--3dx-r.is-active .hamburger-inner::after {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
-}
-
-/*
- * 3DY
- */
-.hamburger--3dy .hamburger-box {
- perspective: 80px;
-}
-
-.hamburger--3dy .hamburger-inner {
- transition: transform 0.15s cubic-bezier(0.645, 0.045, 0.355, 1),
- background-color 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-.hamburger--3dy .hamburger-inner::before,
-.hamburger--3dy .hamburger-inner::after {
- transition: transform 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hamburger--3dy.is-active .hamburger-inner {
- background-color: transparent;
- transform: rotateX(-180deg);
-}
-.hamburger--3dy.is-active .hamburger-inner::before {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--3dy.is-active .hamburger-inner::after {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
-}
-
-/*
- * 3DY Reverse
- */
-.hamburger--3dy-r .hamburger-box {
- perspective: 80px;
-}
-
-.hamburger--3dy-r .hamburger-inner {
- transition: transform 0.15s cubic-bezier(0.645, 0.045, 0.355, 1),
- background-color 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-.hamburger--3dy-r .hamburger-inner::before,
-.hamburger--3dy-r .hamburger-inner::after {
- transition: transform 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hamburger--3dy-r.is-active .hamburger-inner {
- background-color: transparent;
- transform: rotateX(180deg);
-}
-.hamburger--3dy-r.is-active .hamburger-inner::before {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--3dy-r.is-active .hamburger-inner::after {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
-}
-
-/*
- * 3DXY
- */
-.hamburger--3dxy .hamburger-box {
- perspective: 80px;
-}
-
-.hamburger--3dxy .hamburger-inner {
- transition: transform 0.15s cubic-bezier(0.645, 0.045, 0.355, 1),
- background-color 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-.hamburger--3dxy .hamburger-inner::before,
-.hamburger--3dxy .hamburger-inner::after {
- transition: transform 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hamburger--3dxy.is-active .hamburger-inner {
- background-color: transparent;
- transform: rotateX(180deg) rotateY(180deg);
-}
-.hamburger--3dxy.is-active .hamburger-inner::before {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--3dxy.is-active .hamburger-inner::after {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
-}
-
-/*
- * 3DXY Reverse
- */
-.hamburger--3dxy-r .hamburger-box {
- perspective: 80px;
-}
-
-.hamburger--3dxy-r .hamburger-inner {
- transition: transform 0.15s cubic-bezier(0.645, 0.045, 0.355, 1),
- background-color 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-.hamburger--3dxy-r .hamburger-inner::before,
-.hamburger--3dxy-r .hamburger-inner::after {
- transition: transform 0s 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hamburger--3dxy-r.is-active .hamburger-inner {
- background-color: transparent;
- transform: rotateX(180deg) rotateY(180deg) rotateZ(-180deg);
-}
-.hamburger--3dxy-r.is-active .hamburger-inner::before {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--3dxy-r.is-active .hamburger-inner::after {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
-}
-
-/*
- * Arrow
- */
-.hamburger--arrow.is-active .hamburger-inner::before {
- transform: translate3d(-8px, 0, 0) rotate(-45deg) scale(0.7, 1);
-}
-
-.hamburger--arrow.is-active .hamburger-inner::after {
- transform: translate3d(-8px, 0, 0) rotate(45deg) scale(0.7, 1);
-}
-
-/*
- * Arrow Right
- */
-.hamburger--arrow-r.is-active .hamburger-inner::before {
- transform: translate3d(8px, 0, 0) rotate(45deg) scale(0.7, 1);
-}
-
-.hamburger--arrow-r.is-active .hamburger-inner::after {
- transform: translate3d(8px, 0, 0) rotate(-45deg) scale(0.7, 1);
-}
-
-/*
- * Arrow Alt
- */
-.hamburger--arrowalt .hamburger-inner::before {
- transition: top 0.1s 0.1s ease, transform 0.1s cubic-bezier(0.165, 0.84, 0.44, 1);
-}
-
-.hamburger--arrowalt .hamburger-inner::after {
- transition: bottom 0.1s 0.1s ease, transform 0.1s cubic-bezier(0.165, 0.84, 0.44, 1);
-}
-
-.hamburger--arrowalt.is-active .hamburger-inner::before {
- top: 0;
- transform: translate3d(-8px, -10px, 0) rotate(-45deg) scale(0.7, 1);
- transition: top 0.1s ease, transform 0.1s 0.1s cubic-bezier(0.895, 0.03, 0.685, 0.22);
-}
-
-.hamburger--arrowalt.is-active .hamburger-inner::after {
- bottom: 0;
- transform: translate3d(-8px, 10px, 0) rotate(45deg) scale(0.7, 1);
- transition: bottom 0.1s ease, transform 0.1s 0.1s cubic-bezier(0.895, 0.03, 0.685, 0.22);
-}
-
-/*
- * Arrow Alt Right
- */
-.hamburger--arrowalt-r .hamburger-inner::before {
- transition: top 0.1s 0.1s ease, transform 0.1s cubic-bezier(0.165, 0.84, 0.44, 1);
-}
-
-.hamburger--arrowalt-r .hamburger-inner::after {
- transition: bottom 0.1s 0.1s ease, transform 0.1s cubic-bezier(0.165, 0.84, 0.44, 1);
-}
-
-.hamburger--arrowalt-r.is-active .hamburger-inner::before {
- top: 0;
- transform: translate3d(8px, -10px, 0) rotate(45deg) scale(0.7, 1);
- transition: top 0.1s ease, transform 0.1s 0.1s cubic-bezier(0.895, 0.03, 0.685, 0.22);
-}
-
-.hamburger--arrowalt-r.is-active .hamburger-inner::after {
- bottom: 0;
- transform: translate3d(8px, 10px, 0) rotate(-45deg) scale(0.7, 1);
- transition: bottom 0.1s ease, transform 0.1s 0.1s cubic-bezier(0.895, 0.03, 0.685, 0.22);
-}
-
-/*
- * Arrow Turn
- */
-.hamburger--arrowturn.is-active .hamburger-inner {
- transform: rotate(-180deg);
-}
-.hamburger--arrowturn.is-active .hamburger-inner::before {
- transform: translate3d(8px, 0, 0) rotate(45deg) scale(0.7, 1);
-}
-.hamburger--arrowturn.is-active .hamburger-inner::after {
- transform: translate3d(8px, 0, 0) rotate(-45deg) scale(0.7, 1);
-}
-
-/*
- * Arrow Turn Right
- */
-.hamburger--arrowturn-r.is-active .hamburger-inner {
- transform: rotate(-180deg);
-}
-.hamburger--arrowturn-r.is-active .hamburger-inner::before {
- transform: translate3d(-8px, 0, 0) rotate(-45deg) scale(0.7, 1);
-}
-.hamburger--arrowturn-r.is-active .hamburger-inner::after {
- transform: translate3d(-8px, 0, 0) rotate(45deg) scale(0.7, 1);
-}
-
-/*
- * Boring
- */
-.hamburger--boring .hamburger-inner,
-.hamburger--boring .hamburger-inner::before,
-.hamburger--boring .hamburger-inner::after {
- transition-property: none;
-}
-
-.hamburger--boring.is-active .hamburger-inner {
- transform: rotate(45deg);
-}
-.hamburger--boring.is-active .hamburger-inner::before {
- top: 0;
- opacity: 0;
-}
-.hamburger--boring.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(-90deg);
-}
-
-/*
- * Collapse
- */
-.hamburger--collapse .hamburger-inner {
- top: auto;
- bottom: 0;
- transition-duration: 0.13s;
- transition-delay: 0.13s;
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--collapse .hamburger-inner::after {
- top: -20px;
- transition: top 0.2s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1), opacity 0.1s linear;
-}
-.hamburger--collapse .hamburger-inner::before {
- transition: top 0.12s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1),
- transform 0.13s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--collapse.is-active .hamburger-inner {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
- transition-delay: 0.22s;
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--collapse.is-active .hamburger-inner::after {
- top: 0;
- opacity: 0;
- transition: top 0.2s cubic-bezier(0.33333, 0, 0.66667, 0.33333), opacity 0.1s 0.22s linear;
-}
-.hamburger--collapse.is-active .hamburger-inner::before {
- top: 0;
- transform: rotate(-90deg);
- transition: top 0.1s 0.16s cubic-bezier(0.33333, 0, 0.66667, 0.33333),
- transform 0.13s 0.25s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Collapse Reverse
- */
-.hamburger--collapse-r .hamburger-inner {
- top: auto;
- bottom: 0;
- transition-duration: 0.13s;
- transition-delay: 0.13s;
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--collapse-r .hamburger-inner::after {
- top: -20px;
- transition: top 0.2s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1), opacity 0.1s linear;
-}
-.hamburger--collapse-r .hamburger-inner::before {
- transition: top 0.12s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1),
- transform 0.13s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--collapse-r.is-active .hamburger-inner {
- transform: translate3d(0, -10px, 0) rotate(45deg);
- transition-delay: 0.22s;
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--collapse-r.is-active .hamburger-inner::after {
- top: 0;
- opacity: 0;
- transition: top 0.2s cubic-bezier(0.33333, 0, 0.66667, 0.33333), opacity 0.1s 0.22s linear;
-}
-.hamburger--collapse-r.is-active .hamburger-inner::before {
- top: 0;
- transform: rotate(90deg);
- transition: top 0.1s 0.16s cubic-bezier(0.33333, 0, 0.66667, 0.33333),
- transform 0.13s 0.25s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Elastic
- */
-.hamburger--elastic .hamburger-inner {
- top: 2px;
- transition-duration: 0.275s;
- transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
-}
-.hamburger--elastic .hamburger-inner::before {
- top: 10px;
- transition: opacity 0.125s 0.275s ease;
-}
-.hamburger--elastic .hamburger-inner::after {
- top: 20px;
- transition: transform 0.275s cubic-bezier(0.68, -0.55, 0.265, 1.55);
-}
-
-.hamburger--elastic.is-active .hamburger-inner {
- transform: translate3d(0, 10px, 0) rotate(135deg);
- transition-delay: 0.075s;
-}
-.hamburger--elastic.is-active .hamburger-inner::before {
- transition-delay: 0s;
- opacity: 0;
-}
-.hamburger--elastic.is-active .hamburger-inner::after {
- transform: translate3d(0, -20px, 0) rotate(-270deg);
- transition-delay: 0.075s;
-}
-
-/*
- * Elastic Reverse
- */
-.hamburger--elastic-r .hamburger-inner {
- top: 2px;
- transition-duration: 0.275s;
- transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
-}
-.hamburger--elastic-r .hamburger-inner::before {
- top: 10px;
- transition: opacity 0.125s 0.275s ease;
-}
-.hamburger--elastic-r .hamburger-inner::after {
- top: 20px;
- transition: transform 0.275s cubic-bezier(0.68, -0.55, 0.265, 1.55);
-}
-
-.hamburger--elastic-r.is-active .hamburger-inner {
- transform: translate3d(0, 10px, 0) rotate(-135deg);
- transition-delay: 0.075s;
-}
-.hamburger--elastic-r.is-active .hamburger-inner::before {
- transition-delay: 0s;
- opacity: 0;
-}
-.hamburger--elastic-r.is-active .hamburger-inner::after {
- transform: translate3d(0, -20px, 0) rotate(270deg);
- transition-delay: 0.075s;
-}
-
-/*
- * Emphatic
- */
-.hamburger--emphatic {
- overflow: hidden;
-}
-.hamburger--emphatic .hamburger-inner {
- transition: background-color 0.125s 0.175s ease-in;
-}
-.hamburger--emphatic .hamburger-inner::before {
- left: 0;
- transition: transform 0.125s cubic-bezier(0.6, 0.04, 0.98, 0.335), top 0.05s 0.125s linear,
- left 0.125s 0.175s ease-in;
-}
-.hamburger--emphatic .hamburger-inner::after {
- top: 10px;
- right: 0;
- transition: transform 0.125s cubic-bezier(0.6, 0.04, 0.98, 0.335), top 0.05s 0.125s linear,
- right 0.125s 0.175s ease-in;
-}
-.hamburger--emphatic.is-active .hamburger-inner {
- transition-delay: 0s;
- transition-timing-function: ease-out;
- background-color: transparent;
-}
-.hamburger--emphatic.is-active .hamburger-inner::before {
- left: -80px;
- top: -80px;
- transform: translate3d(80px, 80px, 0) rotate(45deg);
- transition: left 0.125s ease-out, top 0.05s 0.125s linear,
- transform 0.125s 0.175s cubic-bezier(0.075, 0.82, 0.165, 1);
-}
-.hamburger--emphatic.is-active .hamburger-inner::after {
- right: -80px;
- top: -80px;
- transform: translate3d(-80px, 80px, 0) rotate(-45deg);
- transition: right 0.125s ease-out, top 0.05s 0.125s linear,
- transform 0.125s 0.175s cubic-bezier(0.075, 0.82, 0.165, 1);
-}
-
-/*
- * Emphatic Reverse
- */
-.hamburger--emphatic-r {
- overflow: hidden;
-}
-.hamburger--emphatic-r .hamburger-inner {
- transition: background-color 0.125s 0.175s ease-in;
-}
-.hamburger--emphatic-r .hamburger-inner::before {
- left: 0;
- transition: transform 0.125s cubic-bezier(0.6, 0.04, 0.98, 0.335), top 0.05s 0.125s linear,
- left 0.125s 0.175s ease-in;
-}
-.hamburger--emphatic-r .hamburger-inner::after {
- top: 10px;
- right: 0;
- transition: transform 0.125s cubic-bezier(0.6, 0.04, 0.98, 0.335), top 0.05s 0.125s linear,
- right 0.125s 0.175s ease-in;
-}
-.hamburger--emphatic-r.is-active .hamburger-inner {
- transition-delay: 0s;
- transition-timing-function: ease-out;
- background-color: transparent;
-}
-.hamburger--emphatic-r.is-active .hamburger-inner::before {
- left: -80px;
- top: 80px;
- transform: translate3d(80px, -80px, 0) rotate(-45deg);
- transition: left 0.125s ease-out, top 0.05s 0.125s linear,
- transform 0.125s 0.175s cubic-bezier(0.075, 0.82, 0.165, 1);
-}
-.hamburger--emphatic-r.is-active .hamburger-inner::after {
- right: -80px;
- top: 80px;
- transform: translate3d(-80px, -80px, 0) rotate(45deg);
- transition: right 0.125s ease-out, top 0.05s 0.125s linear,
- transform 0.125s 0.175s cubic-bezier(0.075, 0.82, 0.165, 1);
-}
-
-/*
- * Minus
- */
-.hamburger--minus .hamburger-inner::before,
-.hamburger--minus .hamburger-inner::after {
- transition: bottom 0.08s 0s ease-out, top 0.08s 0s ease-out, opacity 0s linear;
-}
-
-.hamburger--minus.is-active .hamburger-inner::before,
-.hamburger--minus.is-active .hamburger-inner::after {
- opacity: 0;
- transition: bottom 0.08s ease-out, top 0.08s ease-out, opacity 0s 0.08s linear;
-}
-
-.hamburger--minus.is-active .hamburger-inner::before {
- top: 0;
-}
-
-.hamburger--minus.is-active .hamburger-inner::after {
- bottom: 0;
-}
-
-/*
- * Slider
- */
-.hamburger--slider .hamburger-inner {
- top: 2px;
-}
-.hamburger--slider .hamburger-inner::before {
- top: 10px;
- transition-property: transform, opacity;
- transition-timing-function: ease;
- transition-duration: 0.15s;
-}
-.hamburger--slider .hamburger-inner::after {
- top: 20px;
-}
-
-.hamburger--slider.is-active .hamburger-inner {
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--slider.is-active .hamburger-inner::before {
- transform: rotate(-45deg) translate3d(-5.71429px, -6px, 0);
- opacity: 0;
-}
-.hamburger--slider.is-active .hamburger-inner::after {
- transform: translate3d(0, -20px, 0) rotate(-90deg);
-}
-
-/*
- * Slider Reverse
- */
-.hamburger--slider-r .hamburger-inner {
- top: 2px;
-}
-.hamburger--slider-r .hamburger-inner::before {
- top: 10px;
- transition-property: transform, opacity;
- transition-timing-function: ease;
- transition-duration: 0.15s;
-}
-.hamburger--slider-r .hamburger-inner::after {
- top: 20px;
-}
-
-.hamburger--slider-r.is-active .hamburger-inner {
- transform: translate3d(0, 10px, 0) rotate(-45deg);
-}
-.hamburger--slider-r.is-active .hamburger-inner::before {
- transform: rotate(45deg) translate3d(5.71429px, -6px, 0);
- opacity: 0;
-}
-.hamburger--slider-r.is-active .hamburger-inner::after {
- transform: translate3d(0, -20px, 0) rotate(90deg);
-}
-
-/*
- * Spin
- */
-.hamburger--spin .hamburger-inner {
- transition-duration: 0.22s;
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--spin .hamburger-inner::before {
- transition: top 0.1s 0.25s ease-in, opacity 0.1s ease-in;
-}
-.hamburger--spin .hamburger-inner::after {
- transition: bottom 0.1s 0.25s ease-in, transform 0.22s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--spin.is-active .hamburger-inner {
- transform: rotate(225deg);
- transition-delay: 0.12s;
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--spin.is-active .hamburger-inner::before {
- top: 0;
- opacity: 0;
- transition: top 0.1s ease-out, opacity 0.1s 0.12s ease-out;
-}
-.hamburger--spin.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(-90deg);
- transition: bottom 0.1s ease-out, transform 0.22s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Spin Reverse
- */
-.hamburger--spin-r .hamburger-inner {
- transition-duration: 0.22s;
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--spin-r .hamburger-inner::before {
- transition: top 0.1s 0.25s ease-in, opacity 0.1s ease-in;
-}
-.hamburger--spin-r .hamburger-inner::after {
- transition: bottom 0.1s 0.25s ease-in, transform 0.22s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--spin-r.is-active .hamburger-inner {
- transform: rotate(-225deg);
- transition-delay: 0.12s;
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--spin-r.is-active .hamburger-inner::before {
- top: 0;
- opacity: 0;
- transition: top 0.1s ease-out, opacity 0.1s 0.12s ease-out;
-}
-.hamburger--spin-r.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(90deg);
- transition: bottom 0.1s ease-out, transform 0.22s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Spring
- */
-.hamburger--spring .hamburger-inner {
- top: 2px;
- transition: background-color 0s 0.13s linear;
-}
-.hamburger--spring .hamburger-inner::before {
- top: 10px;
- transition: top 0.1s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1),
- transform 0.13s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--spring .hamburger-inner::after {
- top: 20px;
- transition: top 0.2s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1),
- transform 0.13s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--spring.is-active .hamburger-inner {
- transition-delay: 0.22s;
- background-color: transparent;
-}
-.hamburger--spring.is-active .hamburger-inner::before {
- top: 0;
- transition: top 0.1s 0.15s cubic-bezier(0.33333, 0, 0.66667, 0.33333),
- transform 0.13s 0.22s cubic-bezier(0.215, 0.61, 0.355, 1);
- transform: translate3d(0, 10px, 0) rotate(45deg);
-}
-.hamburger--spring.is-active .hamburger-inner::after {
- top: 0;
- transition: top 0.2s cubic-bezier(0.33333, 0, 0.66667, 0.33333),
- transform 0.13s 0.22s cubic-bezier(0.215, 0.61, 0.355, 1);
- transform: translate3d(0, 10px, 0) rotate(-45deg);
-}
-
-/*
- * Spring Reverse
- */
-.hamburger--spring-r .hamburger-inner {
- top: auto;
- bottom: 0;
- transition-duration: 0.13s;
- transition-delay: 0s;
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--spring-r .hamburger-inner::after {
- top: -20px;
- transition: top 0.2s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1), opacity 0s linear;
-}
-.hamburger--spring-r .hamburger-inner::before {
- transition: top 0.1s 0.2s cubic-bezier(0.33333, 0.66667, 0.66667, 1),
- transform 0.13s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--spring-r.is-active .hamburger-inner {
- transform: translate3d(0, -10px, 0) rotate(-45deg);
- transition-delay: 0.22s;
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--spring-r.is-active .hamburger-inner::after {
- top: 0;
- opacity: 0;
- transition: top 0.2s cubic-bezier(0.33333, 0, 0.66667, 0.33333), opacity 0s 0.22s linear;
-}
-.hamburger--spring-r.is-active .hamburger-inner::before {
- top: 0;
- transform: rotate(90deg);
- transition: top 0.1s 0.15s cubic-bezier(0.33333, 0, 0.66667, 0.33333),
- transform 0.13s 0.22s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Stand
- */
-.hamburger--stand .hamburger-inner {
- transition: transform 0.075s 0.15s cubic-bezier(0.55, 0.055, 0.675, 0.19),
- background-color 0s 0.075s linear;
-}
-.hamburger--stand .hamburger-inner::before {
- transition: top 0.075s 0.075s ease-in, transform 0.075s 0s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--stand .hamburger-inner::after {
- transition: bottom 0.075s 0.075s ease-in,
- transform 0.075s 0s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--stand.is-active .hamburger-inner {
- transform: rotate(90deg);
- background-color: transparent;
- transition: transform 0.075s 0s cubic-bezier(0.215, 0.61, 0.355, 1),
- background-color 0s 0.15s linear;
-}
-.hamburger--stand.is-active .hamburger-inner::before {
- top: 0;
- transform: rotate(-45deg);
- transition: top 0.075s 0.1s ease-out, transform 0.075s 0.15s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--stand.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(45deg);
- transition: bottom 0.075s 0.1s ease-out,
- transform 0.075s 0.15s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Stand Reverse
- */
-.hamburger--stand-r .hamburger-inner {
- transition: transform 0.075s 0.15s cubic-bezier(0.55, 0.055, 0.675, 0.19),
- background-color 0s 0.075s linear;
-}
-.hamburger--stand-r .hamburger-inner::before {
- transition: top 0.075s 0.075s ease-in, transform 0.075s 0s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--stand-r .hamburger-inner::after {
- transition: bottom 0.075s 0.075s ease-in,
- transform 0.075s 0s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--stand-r.is-active .hamburger-inner {
- transform: rotate(-90deg);
- background-color: transparent;
- transition: transform 0.075s 0s cubic-bezier(0.215, 0.61, 0.355, 1),
- background-color 0s 0.15s linear;
-}
-.hamburger--stand-r.is-active .hamburger-inner::before {
- top: 0;
- transform: rotate(-45deg);
- transition: top 0.075s 0.1s ease-out, transform 0.075s 0.15s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--stand-r.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(45deg);
- transition: bottom 0.075s 0.1s ease-out,
- transform 0.075s 0.15s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Squeeze
- */
-.hamburger--squeeze .hamburger-inner {
- transition-duration: 0.075s;
- transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-.hamburger--squeeze .hamburger-inner::before {
- transition: top 0.075s 0.12s ease, opacity 0.075s ease;
-}
-.hamburger--squeeze .hamburger-inner::after {
- transition: bottom 0.075s 0.12s ease, transform 0.075s cubic-bezier(0.55, 0.055, 0.675, 0.19);
-}
-
-.hamburger--squeeze.is-active .hamburger-inner {
- transform: rotate(45deg);
- transition-delay: 0.12s;
- transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-.hamburger--squeeze.is-active .hamburger-inner::before {
- top: 0;
- opacity: 0;
- transition: top 0.075s ease, opacity 0.075s 0.12s ease;
-}
-.hamburger--squeeze.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(-90deg);
- transition: bottom 0.075s ease, transform 0.075s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
-}
-
-/*
- * Vortex
- */
-.hamburger--vortex .hamburger-inner {
- transition-duration: 0.2s;
- transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
-}
-.hamburger--vortex .hamburger-inner::before,
-.hamburger--vortex .hamburger-inner::after {
- transition-duration: 0s;
- transition-delay: 0.1s;
- transition-timing-function: linear;
-}
-.hamburger--vortex .hamburger-inner::before {
- transition-property: top, opacity;
-}
-.hamburger--vortex .hamburger-inner::after {
- transition-property: bottom, transform;
-}
-
-.hamburger--vortex.is-active .hamburger-inner {
- transform: rotate(765deg);
- transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
-}
-.hamburger--vortex.is-active .hamburger-inner::before,
-.hamburger--vortex.is-active .hamburger-inner::after {
- transition-delay: 0s;
-}
-.hamburger--vortex.is-active .hamburger-inner::before {
- top: 0;
- opacity: 0;
-}
-.hamburger--vortex.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(90deg);
-}
-
-/*
- * Vortex Reverse
- */
-.hamburger--vortex-r .hamburger-inner {
- transition-duration: 0.2s;
- transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
-}
-.hamburger--vortex-r .hamburger-inner::before,
-.hamburger--vortex-r .hamburger-inner::after {
- transition-duration: 0s;
- transition-delay: 0.1s;
- transition-timing-function: linear;
-}
-.hamburger--vortex-r .hamburger-inner::before {
- transition-property: top, opacity;
-}
-.hamburger--vortex-r .hamburger-inner::after {
- transition-property: bottom, transform;
-}
-
-.hamburger--vortex-r.is-active .hamburger-inner {
- transform: rotate(-765deg);
- transition-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
-}
-.hamburger--vortex-r.is-active .hamburger-inner::before,
-.hamburger--vortex-r.is-active .hamburger-inner::after {
- transition-delay: 0s;
-}
-.hamburger--vortex-r.is-active .hamburger-inner::before {
- top: 0;
- opacity: 0;
-}
-.hamburger--vortex-r.is-active .hamburger-inner::after {
- bottom: 0;
- transform: rotate(-90deg);
-}
diff --git a/src/css/components/header.scss b/src/css/components/header.scss
deleted file mode 100644
index e9a45cc09..000000000
--- a/src/css/components/header.scss
+++ /dev/null
@@ -1,127 +0,0 @@
-.header {
- position: relative;
- padding: 5rem 1rem 4rem;
- background: #5b67ff;
- background: linear-gradient(25deg, #95e2ff, #5f79ff, #8ed5ff);
- color: white;
- margin-bottom: 2rem;
- text-align: center;
- overflow: hidden;
- z-index: 1;
-
- &::before {
- content: '';
- position: absolute;
- width: 150%;
- height: 150%;
- top: 0;
- left: 0;
- opacity: 0.1;
- z-index: -1;
- }
-
- &::after {
- content: '';
- position: absolute;
- 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='%23f2f3f8'/%3E%3C/svg%3E");
- background-size: 24px 24px;
- width: 100%;
- left: 0;
- height: 24px;
- bottom: -7px;
- z-index: 3;
- }
-
- &__content {
- position: relative;
- z-index: 3;
- }
-
- &__logo {
- height: 146px;
- user-select: none;
- }
-
- &__heading {
- font-weight: 300;
- font-size: 3rem;
- margin: 1rem 0;
- line-height: 1.2;
- }
-
- &__description {
- font-size: 1.5rem;
- max-width: 600px;
- margin: 0 auto 2rem;
- font-weight: 300;
- letter-spacing: 0.4px;
- }
-
- &__css {
- font-size: 4rem;
- font-weight: bold;
- }
-
- &__github-button-wrapper {
- height: 28px;
- }
-
- &__github-button {
- color: white;
- }
-
- &__leaves {
- position: absolute;
- width: 250px;
- user-select: none;
- }
-}
-
-#header__blob {
- position: absolute;
- width: 240px;
- left: -25px;
- top: 50px;
- user-select: none;
-}
-
-#header__leaves1 {
- right: -100px;
- top: -50px;
-}
-
-#header__leaves2 {
- left: -250px;
- bottom: -100px;
- transform: rotate(235deg);
- z-index: 2;
- width: 400px;
-}
-
-@media (min-width: 1150px) {
- #header__leaves2 {
- left: -100px;
- transform: rotate(180deg);
- }
-
- #header__blob {
- left: 50px;
- top: 5px;
- }
-}
-
-@media (min-width: 579px) {
- .header {
- padding: 6rem 0 5rem;
-
- &__heading {
- font-size: 3.75rem;
- }
- }
-}
-
-@media (min-width: 992px) {
- .header {
- padding: 2.5rem 0 5rem;
- }
-}
diff --git a/src/css/components/sidebar.scss b/src/css/components/sidebar.scss
deleted file mode 100644
index 0dd3f7e51..000000000
--- a/src/css/components/sidebar.scss
+++ /dev/null
@@ -1,129 +0,0 @@
-.sidebar {
- background: #273149;
- position: fixed;
- z-index: 2;
- width: 100%;
- height: 44px;
- box-shadow: 0 0.25rem 0.5rem -0.1rem rgba(0, 32, 128, 0.2);
-
- &__menu {
- position: absolute;
- font-weight: bold;
- border: none;
- text-align: left;
- text-transform: uppercase;
- left: 0;
- top: 0;
- padding: 0.75rem 1rem;
- outline: 0;
- }
-
- &__menu-icon {
- height: 24px;
- }
-
- &__links {
- background: #273149;
- overflow-y: auto;
- transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
- transform-origin: 0% 0%;
- transform: rotateX(-90deg);
- visibility: hidden;
- opacity: 0;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- max-height: 378px;
- margin-top: 44px;
- box-shadow: 0 0.25rem 0.5rem -0.1rem rgba(0, 32, 128, 0.2);
- padding-bottom: 1rem;
-
- &.is-active {
- transform: rotateX(0);
- visibility: visible;
- opacity: 1;
- }
- }
-
- &__link {
- display: block;
- color: #e3f5ff;
- padding: 0.75rem;
- padding-right: 1.5rem;
- margin-right: -0.75rem;
- transition: all 0.1s ease-out;
- border-left: 2px solid #576a85;
- font-weight: 500;
- font-size: 0.95rem;
-
- &:hover {
- color: #88f4ff;
- background: rgba(255, 255, 255, 0.1);
- border-color: pink;
- }
- }
-
- &__section {
- padding: 0 0.75rem;
- }
-
- &__section-heading {
- text-transform: capitalize;
- color: #e3f5ff;
- margin-bottom: 0.5rem;
- }
-
- &__new {
- width: 1.25rem;
- vertical-align: middle;
- margin-right: 0.25rem;
- }
-}
-
-@media (min-width: 992px) {
- .sidebar {
- left: 0;
- top: 0;
- bottom: 0;
- width: 20%;
- height: 100%;
- background: linear-gradient(-30deg, #273149, #1c273f);
- box-shadow: 0.4rem 0.4rem 0.8rem rgba(0, 32, 64, 0.1);
- overflow-y: auto;
- color: white;
-
- @media (min-width: 1400px) {
- width: 275px;
- }
-
- &__links {
- background: none;
- box-shadow: none;
- visibility: visible;
- opacity: 1;
- transform: rotateX(0);
- margin-top: 0;
- max-height: none;
- }
-
- &__menu {
- display: none;
- }
- }
-}
-
-html:not(.macOS) {
- .sidebar {
- &::-webkit-scrollbar-track {
- background-color: rgba(0, 0, 0, 0.6);
- }
-
- &::-webkit-scrollbar {
- width: 10px;
- background-color: #505b76;
- }
-
- &::-webkit-scrollbar-thumb {
- background-color: #505b76;
- }
- }
-}
diff --git a/src/css/components/snippet.scss b/src/css/components/snippet.scss
deleted file mode 100644
index e614bcf65..000000000
--- a/src/css/components/snippet.scss
+++ /dev/null
@@ -1,148 +0,0 @@
-.snippet {
- position: relative;
- background: white;
- padding: 2rem 5%;
- box-shadow: 0 0.4rem 0.8rem -0.1rem rgba(0, 32, 128, 0.1), 0 0 0 1px #f0f2f7;
- border-radius: 0.25rem;
- font-size: 1.1rem;
- margin-bottom: 1.5rem;
-
- h3 {
- font-size: 2rem;
- padding: 0.5rem 0;
- border-bottom: 1px solid rgba(0, 32, 128, 0.1);
- margin-bottom: 1.25rem;
- margin-top: 0;
- line-height: 1.3;
-
- span:not(.snippet__tag) {
- margin-right: 0.75rem;
- }
- }
-
- code:not([class*='lang']) {
- background: #fcfaff;
- border: 1px solid #e2ddff;
- color: #4b00da;
- border-radius: 0.15rem;
- font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
- font-size: 0.9rem;
- padding: 0.2rem 0.4rem;
- margin: 0 0.1rem;
- }
-
- ol {
- margin-top: 0.5rem;
- }
-
- ol > li {
- margin-bottom: 0.5rem;
- }
-
- > p {
- margin-top: 0.5rem;
- }
-
- h4 {
- display: inline-block;
- margin: 1rem 0 0.5rem;
- font-size: 1.1rem;
- line-height: 2;
-
- &[data-type] {
- background: #333;
- padding: 0 0.5rem;
- border-radius: 3px;
- font-size: 0.9rem;
- text-transform: uppercase;
- border: 1px solid #c6d6ea;
- border-bottom-color: darken(#c6d6ea, 5);
- background: white;
- box-shadow: 0 0.25rem 0.5rem -0.1rem rgba(0, 32, 64, 0.15);
- background-repeat: no-repeat;
- }
-
- &[data-type='HTML'] {
- color: white;
- border: none;
- background-image: linear-gradient(135deg, #ff4c9f, #ff7b74);
- }
- &[data-type='CSS'] {
- color: white;
- border: none;
- background-image: linear-gradient(135deg, #7983ff, #5f9de9);
- }
- &[data-type='JavaScript'] {
- color: white;
- border: none;
- background-image: linear-gradient(135deg, #ffb000, #f58818);
- }
- }
-
- &__browser-support {
- display: inline-block;
- font-size: 2rem;
- font-weight: 200;
- line-height: 1;
- margin: 0.5rem 0;
- }
-
- &__subheading.is-html {
- color: #e22f70;
- }
-
- &__subheading.is-css {
- color: #0a91d4;
- }
-
- &__subheading.is-explanation {
- color: #4b00da;
- }
-
- &__support-note {
- color: #9fa5b5;
- font-weight: bold;
- }
-
- &__requires-javascript {
- position: absolute;
- background: red;
- background: linear-gradient(145deg, #ff003b, #ff4b39);
- color: white;
- padding: 0.25rem 0.5rem;
- font-size: 0.9rem;
- transform: rotate(20deg);
- font-weight: bold;
- top: 1rem;
- right: 0;
- }
-
- &__tag {
- }
-
- &__new {
- position: absolute;
- top: -1rem;
- left: 50%;
- transform: translateX(-50%);
- width: 3rem;
- }
-}
-
-.snippet-demo {
- background: #f5f6f9;
- border-radius: 0.25rem;
- padding: 0.75rem 1.25rem;
-
- &.is-distinct {
- background: linear-gradient(135deg, #ff4c9f, #ff7b74);
- }
-}
-
-@media (min-width: 768px) {
- .snippet {
- &__requires-javascript {
- right: -0.5rem;
- }
- }
-}
diff --git a/src/css/components/tags.scss b/src/css/components/tags.scss
deleted file mode 100644
index 2b1485a46..000000000
--- a/src/css/components/tags.scss
+++ /dev/null
@@ -1,85 +0,0 @@
-.tags {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-wrap: wrap;
- margin-bottom: 1rem;
- padding: 0 1rem;
-
- &__tag {
- display: inline-block;
- position: relative;
- top: -1px;
- font-weight: bold;
- font-size: 0.75rem;
- text-transform: uppercase;
- color: #8385aa;
- white-space: nowrap;
- border: 1px solid #c8cbf2;
- border-radius: 2px;
- vertical-align: middle;
- line-height: 2;
- padding: 0 0.5rem;
- margin: 0 0.1rem;
- transition: all 0.1s ease-out;
- outline: 0;
-
- &.is-large {
- font-size: 0.95rem;
- border-radius: 0.2rem;
-
- .feather {
- top: -2px;
- width: 18px;
- height: 18px;
- }
- }
-
- .feather {
- vertical-align: middle;
- margin-right: 0.25rem;
- position: relative;
- top: -1px;
- width: 14px;
- height: 14px;
- }
- }
-
- button.tags__tag {
- user-select: none;
- cursor: pointer;
- margin-bottom: 1rem;
- margin-right: 1rem;
- background: white;
-
- &:hover {
- background: #8385aa;
- border-color: #8385aa;
- color: white;
- }
-
- &.focus-visible:focus {
- box-shadow: 0 0 0 0.25rem transparentize(#8385aa, 0.5);
- }
-
- &:active {
- box-shadow: inset 0 0.1rem 0.1rem 0.1rem rgba(0, 0, 0, 0.2);
- background: darken(#8385aa, 10);
- border-color: darken(#8385aa, 10);
- }
-
- &.is-active {
- background: #7983ff;
- border-color: #7983ff;
- color: white;
-
- &.focus-visible:focus {
- box-shadow: 0 0 0 0.25rem transparentize(#7983ff, 0.5);
- }
- }
- }
-}
-
-@media (min-width: 579px) {
-}
diff --git a/src/css/deps/prism.css b/src/css/deps/prism.css
deleted file mode 100644
index 077a90133..000000000
--- a/src/css/deps/prism.css
+++ /dev/null
@@ -1,147 +0,0 @@
-code[class*='language-'],
-pre[class*='language-'] {
- color: rgb(215, 236, 255);
- background: none;
- font-family: 'Operator Mono', 'Roboto Mono', Menlo, Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono',
- monospace;
- text-align: left;
- white-space: pre;
- word-spacing: normal;
- word-break: normal;
- word-wrap: normal;
- line-height: 2;
- font-size: 1rem;
- -webkit-overflow-scrolling: touch;
- margin: 0;
-
- -moz-tab-size: 4;
- -o-tab-size: 4;
- tab-size: 4;
-
- -webkit-hyphens: none;
- -moz-hyphens: none;
- -ms-hyphens: none;
- hyphens: none;
-}
-
-pre[class*='language-']::-moz-selection,
-pre[class*='language-'] ::-moz-selection,
-code[class*='language-']::-moz-selection,
-code[class*='language-'] ::-moz-selection {
- text-shadow: none;
- background: #b3d4fc;
-}
-
-pre[class*='language-']::selection,
-pre[class*='language-'] ::selection,
-code[class*='language-']::selection,
-code[class*='language-'] ::selection {
- text-shadow: none;
- background: #b3d4fc;
-}
-
-@media print {
- code[class*='language-'],
- pre[class*='language-'] {
- text-shadow: none;
- }
-}
-
-/* Code blocks */
-pre[class*='language-'] {
- overflow: auto;
- padding: 0.75rem 1.25rem;
-}
-
-pre.is-option {
- margin: 0;
- padding: 0;
-}
-
-:not(pre) > code[class*='language-'],
-pre[class*='language-'] {
- background: linear-gradient(-30deg, #273149, #1c273f);
- border-radius: 0.25rem;
-}
-
-/* Inline code */
-:not(pre) > code[class*='language-'] {
- padding: 0.1em;
- border-radius: 0.3em;
- white-space: normal;
-}
-
-.token.comment,
-.token.prolog,
-.token.doctype,
-.token.cdata {
- color: #8ca2d3;
-}
-
-.token.selector,
-.token.attr-name {
- color: #c7f683;
-}
-
-.token.punctuation {
- color: #5ac8e3;
-}
-
-.namespace {
- opacity: 0.7;
-}
-
-.token.tag {
- color: #2cefd8;
-}
-
-.token.property,
-.token.boolean,
-.token.number,
-.token.constant,
-.token.symbol,
-.token.deleted {
- color: #85b4ff;
-}
-
-.token.string,
-.language-css .token.string,
-.token.url,
-.token.attr-value,
-.token.char,
-.token.builtin,
-.token.inserted {
- color: #ffd694;
-}
-
-.token.operator,
-.token.entity,
-.style .token.string {
- color: #ff9bbe;
-}
-
-.token.important,
-.token.atrule,
-.token.keyword {
- color: #b7adff;
-}
-
-.token.function {
- color: #25d0e5;
-}
-
-.token.regex,
-.token.variable {
- color: #00a8d4;
-}
-
-.token.bold {
- font-weight: bold;
-}
-.token.italic {
- font-style: italic;
-}
-
-.token.entity {
- cursor: help;
-}
diff --git a/src/css/index.scss b/src/css/index.scss
deleted file mode 100644
index a341ee426..000000000
--- a/src/css/index.scss
+++ /dev/null
@@ -1,8 +0,0 @@
-@import './components/base.scss';
-@import './components/hamburger.scss';
-@import './components/sidebar.scss';
-@import './components/header.scss';
-@import './components/snippet.scss';
-@import './components/back-to-top-button.scss';
-@import './components/tags.scss';
-@import './components/buttons.scss';
diff --git a/src/html/components/back-to-top-button.html b/src/html/components/back-to-top-button.html
deleted file mode 100644
index fac84306e..000000000
--- a/src/html/components/back-to-top-button.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/html/components/footer.html b/src/html/components/footer.html
deleted file mode 100644
index 5f6968b80..000000000
--- a/src/html/components/footer.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/html/components/header.html b/src/html/components/header.html
deleted file mode 100644
index ed9eb67c7..000000000
--- a/src/html/components/header.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
diff --git a/src/html/components/main.html b/src/html/components/main.html
deleted file mode 100644
index ed318e4b9..000000000
--- a/src/html/components/main.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/html/components/sidebar.html b/src/html/components/sidebar.html
deleted file mode 100644
index b9fceb908..000000000
--- a/src/html/components/sidebar.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/src/html/components/tags.html b/src/html/components/tags.html
deleted file mode 100644
index 97a84ba3e..000000000
--- a/src/html/components/tags.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/html/index.html b/src/html/index.html
deleted file mode 100644
index 3858121a7..000000000
--- a/src/html/index.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
- 30 Seconds of CSS
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/img/blob.png b/src/img/blob.png
deleted file mode 100644
index 554b11981..000000000
Binary files a/src/img/blob.png and /dev/null differ
diff --git a/src/img/leaves.svg b/src/img/leaves.svg
deleted file mode 100644
index 070148df9..000000000
--- a/src/img/leaves.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/src/img/logo.png b/src/img/logo.png
deleted file mode 100644
index f27b93091..000000000
Binary files a/src/img/logo.png and /dev/null differ
diff --git a/src/img/new.svg b/src/img/new.svg
deleted file mode 100644
index 538a08a00..000000000
--- a/src/img/new.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/src/img/opengraph.png b/src/img/opengraph.png
deleted file mode 100644
index 9540b7493..000000000
Binary files a/src/img/opengraph.png and /dev/null differ
diff --git a/src/js/components/BackToTopButton.js b/src/js/components/BackToTopButton.js
deleted file mode 100644
index 36bcb41d5..000000000
--- a/src/js/components/BackToTopButton.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import jump from 'jump.js'
-import { select, scrollY, easeOutQuint } from '../deps/utils'
-
-const backToTopButton = select('.back-to-top-button')
-
-window.addEventListener('scroll', () => {
- backToTopButton.classList[scrollY() > 500 ? 'add' : 'remove']('is-visible')
-})
-backToTopButton.onclick = () => {
- jump('.header', {
- duration: 750,
- easing: easeOutQuint
- })
-}
diff --git a/src/js/components/CodepenCopy.js b/src/js/components/CodepenCopy.js
deleted file mode 100644
index f4dc6389f..000000000
--- a/src/js/components/CodepenCopy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import { selectAll } from '../deps/utils'
-
-const snippets = selectAll('.snippet')
-snippets.forEach(snippet => {
- var codepenForm = document.createElement('form')
- codepenForm.action = 'https://codepen.io/pen/define'
- codepenForm.method = 'POST'
- codepenForm.target = '_blank'
- var codepenInput = document.createElement('input')
- codepenInput.type = 'hidden'
- codepenInput.name = 'data'
- var codepenButton = document.createElement('button')
- codepenButton.classList = 'btn is-large codepen-btn'
- codepenButton.innerHTML = ' Edit on Codepen'
- var css = snippet.querySelector('pre code.lang-css')
- var html = snippet.querySelector('pre code.lang-html')
- var js = snippet.querySelector('pre code.lang-js')
- var data = {
- css: css.textContent,
- title: snippet.querySelector('h3 > span').textContent,
- html: html ? html.textContent : '',
- js: js ? js.textContent : ''
- }
- codepenInput.value = JSON.stringify(data)
- codepenForm.appendChild(codepenInput)
- codepenForm.appendChild(codepenButton)
- snippet.insertBefore(codepenForm, snippet.querySelector('.snippet-demo').nextSibling)
-})
diff --git a/src/js/components/Sidebar.js b/src/js/components/Sidebar.js
deleted file mode 100644
index 830ca68eb..000000000
--- a/src/js/components/Sidebar.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import jump from 'jump.js'
-import { select, selectAll, easeOutQuint } from '../deps/utils'
-
-const menu = select('.hamburger')
-const links = select('.sidebar__links')
-const sections = selectAll('.sidebar__section')
-const ACTIVE_CLASS = 'is-active'
-
-const toggle = () => {
- if (window.innerWidth <= 991) {
- const els = [menu, links]
- els.forEach(el => el.classList.toggle(ACTIVE_CLASS))
- menu.setAttribute('aria-expanded', menu.classList.contains(ACTIVE_CLASS) ? 'true' : 'false')
- }
-}
-
-menu.addEventListener('click', toggle)
-
-links.addEventListener('click', e => {
- const link = e.target.closest('.sidebar__link')
- if (link) {
- setTimeout(toggle, 50)
- jump(link.getAttribute('href'), {
- duration: 500,
- easing: easeOutQuint,
- offset: window.innerWidth <= 991 ? -64 : -32
- })
- }
-})
-
-document.addEventListener('click', e => {
- if (
- !e.target.closest('.sidebar__links') &&
- !e.target.closest('.hamburger') &&
- links.classList.contains(ACTIVE_CLASS)
- ) {
- toggle()
- }
-})
-
-EventHub.on('Tag.click', data => {
- data.type_new = data.type.map(el => el.dataset.type)
- sections.forEach(section => {
- section.style.display = 'block'
- //console.log(data.type_new.includes('all'))
- if (!data.type_new.includes(section.dataset.type) && !data.type_new.includes('all')) {
- section.style.display = 'none'
- } else {
- section.style.display = ''
- }
- })
-})
-
-export default { toggle }
diff --git a/src/js/components/Snippet.js b/src/js/components/Snippet.js
deleted file mode 100644
index e375ec74d..000000000
--- a/src/js/components/Snippet.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { selectAll } from '../deps/utils'
-
-const snippets = selectAll('.snippet')
-EventHub.on('Tag.click', data => {
- data.type_new = data.type.map(el => el.dataset.type)
- snippets.forEach(snippet => {
- snippet.style.display = 'block'
- if (data.type_new.includes('all')) return
- const tags = selectAll('.tags__tag', snippet)
- if (!tags.some(el => data.type_new.includes(el.dataset.type))) {
- snippet.style.display = 'none'
- } else {
- snippet.style.display = ''
- }
- })
-})
diff --git a/src/js/components/Tag.js b/src/js/components/Tag.js
deleted file mode 100644
index 211d50c74..000000000
--- a/src/js/components/Tag.js
+++ /dev/null
@@ -1,41 +0,0 @@
-import { select, selectAll, on } from '../deps/utils'
-
-const tagButtons = selectAll('button.tags__tag')
-var isShiftSelected = false
-const onClick = function() {
- if (isShiftSelected && this.dataset.type === 'all') {
- tagButtons.forEach(button => button.classList.remove('is-active'))
- this.classList.add('is-active')
- } else if (isShiftSelected) {
- select('button[data-type=all]').classList.remove('is-active')
- if (
- this.classList.contains('is-active') &&
- selectAll('button.tags__tag.is-active').length > 1
- ) {
- this.classList.remove('is-active')
- } else if (this.classList.contains('is-active')) {
- this.classList.remove('is-active')
- select('button[data-type=all]').classList.add('is-active')
- } else {
- this.classList.add('is-active')
- }
- } else {
- tagButtons.forEach(button => button.classList.remove('is-active'))
- this.classList.add('is-active')
- }
- EventHub.emit('Tag.click', {
- type: [...selectAll('button.tags__tag.is-active')]
- })
-}
-onkeydown = e => {
- if (e.shiftKey) {
- isShiftSelected = true
- }
-}
-
-onkeyup = e => {
- if (e.key == 'Shift') {
- isShiftSelected = false
- }
-}
-tagButtons.forEach(button => on(button, 'click', onClick))
diff --git a/src/js/deps/polyfills.js b/src/js/deps/polyfills.js
deleted file mode 100644
index d7ee305fd..000000000
--- a/src/js/deps/polyfills.js
+++ /dev/null
@@ -1,16 +0,0 @@
-const e = Element.prototype
-if (!e.matches) {
- e.matches =
- e.matchesSelector || e.msMatchesSelector || e.webkitMatchesSelector || e.mozMatchesSelector
-}
-if (!e.closest) {
- e.closest = function(s) {
- var el = this
- if (!document.documentElement.contains(el)) return null
- do {
- if (el.matches(s)) return el
- el = el.parentElement || el.parentNode
- } while (el !== null && el.nodeType === 1)
- return null
- }
-}
diff --git a/src/js/deps/utils.js b/src/js/deps/utils.js
deleted file mode 100644
index b25071001..000000000
--- a/src/js/deps/utils.js
+++ /dev/null
@@ -1,77 +0,0 @@
-export const select = (s, parent = document) => parent.querySelector(s)
-
-export const selectAll = (s, parent = document) => [].slice.call(parent.querySelectorAll(s))
-
-export const scrollY = () => window.scrollY || window.pageYOffset
-
-export const easeOutQuint = (t, b, c, d) => c * ((t = t / d - 1) * t ** 4 + 1) + b
-
-export const on = (el, evt, fn, opts = {}) => {
- const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e)
- el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false)
- if (opts.target) return delegatorFn
-}
-
-export const createEventHub = () => ({
- hub: Object.create(null),
- emit(event, data) {
- ;(this.hub[event] || []).forEach(handler => handler(data))
- },
- on(event, handler) {
- if (!this.hub[event]) this.hub[event] = []
- this.hub[event].push(handler)
- },
- off(event, handler) {
- const i = (this.hub[event] || []).findIndex(h => h === handler)
- if (i > -1) this.hub[event].splice(i, 1)
- }
-})
-
-window.EventHub = createEventHub()
-
-/*
- * Make iOS behave normally.
- */
-if (/iPhone|iPad|iPod/.test(navigator.platform) && !window.MSStream) {
- document.body.style.cursor = 'pointer'
-}
-
-if (/Mac/.test(navigator.platform)) {
- document.documentElement.classList.add('macOS')
-}
-
-/*
- * A small utility to fix the letter kerning on macOS Chrome and Firefox when using the system font
- * (San Francisco). It is now fixed in the text rendering engine in FF 58 and Chrome 64.
- * UPDATE: It appears the applied fix doesn't work when the font is in italics. New fix has been added.
- * Must be applied to all browsers for now.
- */
-;(() => {
- const ua = navigator.userAgent
-
- // macOS 10.11 (El Capitan) came with San Francisco. Previous versions used Helvetica
- const isRelevantMacOS =
- /Mac/.test(navigator.platform) && (ua.match(/OS X 10[._](\d{1,2})/) || [])[1] >= 11
-
- // Chrome v64 and FF v58 fix the issue
- const isAffectedBrowser =
- (ua.match(/Chrome\/(\d+)\./) || [])[1] < 64 || (ua.match(/Firefox\/(\d+)\./) || [])[1] < 58
-
- const allEls = [].slice.call(document.querySelectorAll('*'))
-
- if (isRelevantMacOS && isAffectedBrowser) {
- document.documentElement.style.letterSpacing = '-0.3px'
- allEls.forEach(el => {
- const fontSize = parseFloat(getComputedStyle(el).fontSize)
- if (fontSize >= 20) el.style.letterSpacing = '0.3px'
- })
- } else if (isRelevantMacOS && !isAffectedBrowser) {
- // Italics fix
- allEls.forEach(el => {
- const { fontSize, fontStyle } = getComputedStyle(el)
- if (fontStyle === 'italic') {
- el.style.letterSpacing = parseFloat(fontSize) >= 20 ? '0.3px' : '-0.3px'
- }
- })
- }
-})()
diff --git a/src/js/index.js b/src/js/index.js
deleted file mode 100644
index 3bb46db20..000000000
--- a/src/js/index.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Deps
-import 'focus-visible'
-import 'normalize.css'
-import 'prismjs'
-import feather from 'feather-icons'
-feather.replace()
-
-// CSS
-import '../css/deps/prism.css'
-import '../css/index.scss'
-
-// Polyfills
-import './deps/polyfills'
-
-// Components
-import Sidebar from './components/Sidebar'
-import BackToTopButton from './components/BackToTopButton'
-import Tag from './components/Tag'
-import Snippet from './components/Snippet'
-import CodepenCopy from './components/CodepenCopy'
diff --git a/src/static-parts/README-end.md b/src/static-parts/README-end.md
new file mode 100644
index 000000000..1754176ca
--- /dev/null
+++ b/src/static-parts/README-end.md
@@ -0,0 +1,3 @@
+---
+
+_This README is built using [markdown-builder](https://github.com/30-seconds/markdown-builder)._
diff --git a/src/static-parts/README-start.md b/src/static-parts/README-start.md
new file mode 100644
index 000000000..482f1ab7a
--- /dev/null
+++ b/src/static-parts/README-start.md
@@ -0,0 +1,22 @@
+# 30 Seconds of CSS
+
+
+
+[](https://github.com/30-seconds/30-seconds-of-css/blob/master/LICENSE) [](http://makeapullrequest.com) [](https://insight.io/github.com/30-seconds/30-seconds-of-css/tree/master/?source=0)
+
+A curated collection of useful CSS snippets you can understand in 30 seconds or less.
+Inspired by [30 seconds of code](https://github.com/30-seconds/30-seconds-of-code).
+
+## View online
+
+https://css.30secondsofcode.org
+
+## Contributing
+
+See CONTRIBUTING.md for the snippet template.
+
+#### Related projects
+
+- [30 Seconds of Code](https://30secondsofcode.org/)
+- [30 Seconds of Interviews](https://30secondsofinterviews.org/)
+- [30 Seconds of React](https://github.com/30-seconds/30-seconds-of-react)
diff --git a/utils/utils.js b/utils/utils.js
deleted file mode 100644
index 9a3b68512..000000000
--- a/utils/utils.js
+++ /dev/null
@@ -1,23 +0,0 @@
-const fs = require('fs')
-const { JSDOM } = require('jsdom')
-
-exports.toKebabCase = str =>
- str &&
- str
- .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
- .map(x => x.toLowerCase())
- .join('-')
-
-exports.dom = path => {
- const doc = new JSDOM(fs.readFileSync(path, 'utf8')).window.document
- return path.includes('component') ? doc.body.firstElementChild : doc
-}
-
-exports.createElement = str => {
- const el = new JSDOM().window.document.createElement('div')
- el.innerHTML = str
- return el.firstElementChild
-}
-
-exports.getCode = (type, str) =>
- (str.match(new RegExp('```' + type + '([\\s\\S]*?)```')) || [])[1] || ''