diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index f2e312799..000000000
--- a/.babelrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "presets": ["env", "stage-2"]
-}
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..cf01b6ad4
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,8 @@
+src/docs/* linguist-documentation
+scripts/* linguist-documentation
+gatsby-browser.js linguist-documentation
+gatsby-config.js linguist-documentation
+gatsby-node.js linguist-documentation
+gatsby-ssr.js linguist-documentation
+.travis/* linguist-documentation
+config.js linguist-documentation
diff --git a/.gitignore b/.gitignore
index ae7a50935..29d9977a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,73 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
node_modules/
+jspm_packages/
+
+# TypeScript v1 declaration files
+typings/
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn
+yarn-error.log
+.pnp/
+.pnp.js
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+
+# next.js build output
+.next
+
+# gatsby files
.cache/
-.DS_Store
-dist/
+public
+
+# Mac files
+.DS_Store
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 0a3613911..cc831c8ff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,13 @@
language: node_js
-node_js:
- - node
-install:
- - npm install
-script:
- - npm run build
-after_script:
- - test $TRAVIS_EVENT_TYPE = cron
- && echo -e "\e[95mDeploying to Repository"
- && chmod +x .travis/push.sh
- && ./.travis/push.sh
- - chmod +x .travis/forcepush.sh && ./.travis/forcepush.sh
cache:
directories:
- - node_modules
\ No newline at end of file
+ - node_modules
+node_js:
+- lts/*
+script:
+- npm run linter
+- npm run extractor
+- npm run builder
+after_success:
+- chmod +x .travis/push.sh
+- .travis/push.sh
\ No newline at end of file
diff --git a/.travis/forcepush.sh b/.travis/forcepush.sh
deleted file mode 100644
index 54f15f5a5..000000000
--- a/.travis/forcepush.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-if [[ $TRAVIS_COMMIT_MESSAGE == *"--force-build"* ]];
- then echo -e "\e[95mFORCE-DEPLOY: Deploying to Repository" && chmod +x .travis/push.sh && ./.travis/push.sh;
-fi
diff --git a/.travis/push.sh b/.travis/push.sh
index a6c1eb6b1..fdd85ca67 100644
--- a/.travis/push.sh
+++ b/.travis/push.sh
@@ -12,8 +12,10 @@ commit_website_files() {
git add *
if [ $TRAVIS_EVENT_TYPE == "cron" ]; then
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER [cron]"
+ elif [ $TRAVIS_EVENT_TYPE == "api" ]; then
+ git commit --message "Travis build: $TRAVIS_BUILD_NUMBER [custom]"
else
- git commit --message "Travis build: $TRAVIS_BUILD_NUMBER [FORCED]"
+ git commit --message "Travis build: $TRAVIS_BUILD_NUMBER"
fi
fi
fi
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0f6746904..45cbfd919 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,34 +1,43 @@
-### Snippet name
+# Contribution guidelines
-Brief description
+**30 seconds of CSS** is a community effort, so feel free to contribute in any way you can. Every contribution helps!
-#### HTML
+Here's what you can do to help:
-```html
+- Submit [pull requests](https://github.com/30-seconds/30-seconds-of-css/pulls) with snippets and tests that you have created (see below for guidelines).
+- [Open issues](https://github.com/30-seconds/30-seconds-of-css/issues/new) for things you want to see added or modified.
+- Be part of the discussion by helping out with [existing issues](https://github.com/30-seconds/30-seconds-of-css/issues).
+- Tag uncategorized snippets by adding the appropriate in the snippet's frontmatter in `tags`.
+- Fix typos in existing snippets, improve snippet descriptions and explanations or provide better examples.
-```
+### Snippet submission and Pull request guidelines
-#### CSS
-
-```css
-```
-
-#### Demo
-
-
-
-#### Explanation
-
-
-
-#### Browser support
-
-
-
-⚠️ Caveat?
-
-
-
-- https://caniuse.com/#feat=some-feature
-
-
+- **DO NOT MODIFY THE README.md FILE!** Make changes to individual snippet files. **Travis CI** will automatically build the `README.md` file when your pull request is merged.
+- **Snippet filenames** must correspond to the title of the snippet. For example, if your snippet is titled `awesomeSnippet` the filename should be `awesomeSnippet.md`.
+ - Use `camelCase` or `kebab-case`, not `snake_case`.
+ - Avoid capitalization of words, except if the whole word is capitalized (e.g. `URL` should be capitalized in the filename and the snippet title).
+- **Snippet metadata** must be included in all snippets in the form of frontmatter.
+ - All snippets must contain a title.
+ - All snippets must contain tags, prefixed with `tags:` and separated by commas (optional spaces in-between).
+ - Make sure the first tag in your snippet's tags is one of the main categories, as seen in the `README.md` file or the website.
+ - Snippet tags must include a difficulty setting (`begginer`, `intermediate` or `advanced`), preferrably at the end of the list.
+- **Snippet titles** should be the same as the name of the function that is present in the snippet.
+ - All snippet titles must be prefixed with `title:` and be at the very first line of your snippet's frontmatter.
+ - Snippet titles must be unique (although if you cannot find a better title, just add some placeholder at the end of the filename and title and we will figure it out).
+ - Follow snippet titles with an empty line.
+- **Snippet descriptions** must be short and to the point. Try to explain *what* the snippet does and *how* the snippet works and what Javascript features are used. Remember to include what functions you are using and why.
+ - Follow snippet descriptions with an empty line.
+- **Snippet code** must be enclosed inside ` ```html `, ` ```css ` or ` ```js ` and ` ``` `.
+ - Remember to start your snippet's code on a new line below the opening backticks.
+ - Please use Javascript [Semi-Standard Style](https://github.com/Flet/semistandard).
+ - Try to keep your snippet's code short and to the point. Use modern techniques and features. Make sure to test your code before submitting.
+ - Try to make your snippet's name unique, so that it does not conflict with existing snippets.
+- **Snippet explanations** should be written as lists of points, describing the implemented functionality.
+ - Use unordered lists if you have a few points, otherwise use an ordered list.
+ - If you have JavaScript functionality in your snippet, it might be worthwhile separating the explanation with it, by adding a new list or a horizontal line break (`---`).
+- **Snippet browser support** should be specified as a list of links to https://www.caniuse.com/ features.
+ - Use the `#` next to the feature that you want in the website to get a link to it.
+- Snippets should be short. If your snippet is long, you can still submit it, and we can help you shorten it or figure out ways to improve it.
+- Snippets *should* solve real-world problems, no matter how simple.
+- Snippets *should* be abstract enough to be applied to different scenarios.
+- You can start creating a new snippet, by using the [snippet template](snippet-template.md) to format your snippets.
diff --git a/README.md b/README.md
index 6ef0d137c..9ca5a3fee 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,2418 @@ 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
+
+100.0%
+
+- 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
+
+100.0%
+
+(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: that the 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.
+
+- 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
+
+100.0%
+
+
+
+
+ [⬆ 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
+
+100.0%
+
+
+
+
+ [⬆ 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
+
+
+- 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/_headers b/_headers
new file mode 100644
index 000000000..4c2f41f08
--- /dev/null
+++ b/_headers
@@ -0,0 +1,4 @@
+[[headers]]
+for = "/static/*"
+[headers.values]
+Cache-Control = "public, max-age=360000"
\ No newline at end of file
diff --git a/advanced.svg b/advanced.svg
new file mode 100644
index 000000000..428312a3c
--- /dev/null
+++ b/advanced.svg
@@ -0,0 +1 @@
+advanced advanced
diff --git a/assets/30s-icon.png b/assets/30s-icon.png
new file mode 100644
index 000000000..56350cc81
Binary files /dev/null and b/assets/30s-icon.png differ
diff --git a/assets/NotoSans-Bold.ttf b/assets/NotoSans-Bold.ttf
new file mode 100644
index 000000000..ab11d3163
Binary files /dev/null and b/assets/NotoSans-Bold.ttf differ
diff --git a/assets/NotoSans-Italic.ttf b/assets/NotoSans-Italic.ttf
new file mode 100644
index 000000000..6d2c71c86
Binary files /dev/null and b/assets/NotoSans-Italic.ttf differ
diff --git a/assets/NotoSans-Light.ttf b/assets/NotoSans-Light.ttf
new file mode 100644
index 000000000..404ed0787
Binary files /dev/null and b/assets/NotoSans-Light.ttf differ
diff --git a/assets/NotoSans-LightItalic.ttf b/assets/NotoSans-LightItalic.ttf
new file mode 100644
index 000000000..4c338dba3
Binary files /dev/null and b/assets/NotoSans-LightItalic.ttf differ
diff --git a/assets/NotoSans-Medium.ttf b/assets/NotoSans-Medium.ttf
new file mode 100644
index 000000000..5dbefd372
Binary files /dev/null and b/assets/NotoSans-Medium.ttf differ
diff --git a/assets/NotoSans-MediumItalic.ttf b/assets/NotoSans-MediumItalic.ttf
new file mode 100644
index 000000000..3641525ea
Binary files /dev/null and b/assets/NotoSans-MediumItalic.ttf differ
diff --git a/assets/NotoSans-Regular.ttf b/assets/NotoSans-Regular.ttf
new file mode 100644
index 000000000..0a01a062f
Binary files /dev/null and b/assets/NotoSans-Regular.ttf differ
diff --git a/assets/NotoSans-SemiBold.ttf b/assets/NotoSans-SemiBold.ttf
new file mode 100644
index 000000000..8b7fd1302
Binary files /dev/null and b/assets/NotoSans-SemiBold.ttf differ
diff --git a/assets/NotoSans-SemiBoldItalic.ttf b/assets/NotoSans-SemiBoldItalic.ttf
new file mode 100644
index 000000000..a7e904c38
Binary files /dev/null and b/assets/NotoSans-SemiBoldItalic.ttf differ
diff --git a/assets/RobotoMono-Italic.woff2 b/assets/RobotoMono-Italic.woff2
new file mode 100644
index 000000000..65d8c7b76
Binary files /dev/null and b/assets/RobotoMono-Italic.woff2 differ
diff --git a/assets/RobotoMono-Medium.woff2 b/assets/RobotoMono-Medium.woff2
new file mode 100644
index 000000000..ec09ab18f
Binary files /dev/null and b/assets/RobotoMono-Medium.woff2 differ
diff --git a/assets/RobotoMono-Regular.woff2 b/assets/RobotoMono-Regular.woff2
new file mode 100644
index 000000000..53d4b505c
Binary files /dev/null and b/assets/RobotoMono-Regular.woff2 differ
diff --git a/src/img/blob.png b/assets/blob.png
similarity index 100%
rename from src/img/blob.png
rename to assets/blob.png
diff --git a/src/img/leaves.svg b/assets/leaves.svg
similarity index 100%
rename from src/img/leaves.svg
rename to assets/leaves.svg
diff --git a/assets/leaves1.png b/assets/leaves1.png
new file mode 100644
index 000000000..4b7d2050c
Binary files /dev/null and b/assets/leaves1.png differ
diff --git a/assets/leaves2.png b/assets/leaves2.png
new file mode 100644
index 000000000..718a01d50
Binary files /dev/null and b/assets/leaves2.png differ
diff --git a/assets/logo.png b/assets/logo.png
new file mode 100644
index 000000000..e1536f79a
Binary files /dev/null and b/assets/logo.png differ
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:/(
- 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
-
-
border-box
-
content-box
-
-
-
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
-
-
-
float a
-
float b
-
float c
-
-
-
-
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
-
-
-
Item1
-
Item2
-
Item3
-
-
-
-
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
-
-
-
Div 1
-
Div 2
-
Div 3
-
-
-
-
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
-
-
- One
- Two
- Three
- Four
-
-
-
-
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
-
-
-
-
-
-
-
-
-
-