diff --git a/docs/3df57813b7ec2de885ea6075ff46ed46.js b/docs/3df57813b7ec2de885ea6075ff46ed46.js index cf7181ed8..cbeb49ad0 100644 --- a/docs/3df57813b7ec2de885ea6075ff46ed46.js +++ b/docs/3df57813b7ec2de885ea6075ff46ed46.js @@ -25,6 +25,6 @@ var o=(0,eval)("this"),n="function"==typeof Symbol&&"symbol"==typeof Symbol.iter "use strict";var t=require("../deps/utils"),e=(0,t.selectAll)(".snippet");EventHub.on("Tag.click",function(l){e.forEach(function(e){(e.style.display="block","all"!==l.type)&&((0,t.selectAll)(".tags__tag",e).some(function(t){return t.dataset.type===l.type})||(e.style.display="none"))})}); },{"../deps/utils":18}],16:[function(require,module,exports) { "use strict";var e=require("../deps/utils"),t=(0,e.selectAll)(".snippet");t.forEach(function(e){var t=document.createElement("form");t.action="https://codepen.io/pen/define",t.method="POST",t.target="_blank";var n=document.createElement("input");n.type="hidden",n.name="data";var r=document.createElement("button");r.classList="btn is-large codepen-btn",r.innerHTML='Edit on Codepen';var o=e.querySelector("pre code.lang-css"),a=e.querySelector("pre code.lang-html"),i=e.querySelector("pre code.lang-js"),l={css:o.textContent,title:e.querySelector("h3 > span").textContent,html:a?a.textContent:"",js:i?i.textContent:""};n.value=JSON.stringify(l),t.appendChild(n),t.appendChild(r),e.insertBefore(t,e.querySelector(".snippet-demo").nextSibling)}); -},{"../deps/utils":18}],7:[function(require,module,exports) { +},{"../deps/utils":18}],8:[function(require,module,exports) { "use strict";require("focus-visible"),require("normalize.css"),require("prismjs");var e=require("feather-icons"),r=l(e);require("../css/deps/prism.css"),require("../css/index.scss"),require("./deps/polyfills");var s=require("./components/Sidebar"),i=l(s),o=require("./components/BackToTopButton"),u=l(o),n=require("./components/Tag"),c=l(n),p=require("./components/Snippet"),t=l(p),q=require("./components/CodepenCopy"),a=l(q);function l(e){return e&&e.__esModule?e:{default:e}}r.default.replace(); -},{"focus-visible":20,"normalize.css":19,"prismjs":22,"feather-icons":21,"../css/deps/prism.css":19,"../css/index.scss":19,"./deps/polyfills":11,"./components/Sidebar":12,"./components/BackToTopButton":13,"./components/Tag":14,"./components/Snippet":15,"./components/CodepenCopy":16}]},{},[7]) \ No newline at end of file +},{"focus-visible":20,"normalize.css":19,"prismjs":22,"feather-icons":21,"../css/deps/prism.css":19,"../css/index.scss":19,"./deps/polyfills":11,"./components/Sidebar":12,"./components/BackToTopButton":13,"./components/Tag":14,"./components/Snippet":15,"./components/CodepenCopy":16}]},{},[8]) \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 6235a87ae..1bc742f93 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,7 +31,7 @@ .bouncing-loader > div:nth-child(3) { animation-delay: 0.4s; } -

Demo

Explanation

Note: 1rem is usually 16px.

  1. @keyframes defines an animation that has two states, where the element changes opacity and is translated up on the 2D plane using transform: translateY().

  2. .bouncing-loader is the parent container of the bouncing circles and uses display: flex and justify-content: center to position them in the center.

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

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

  5. animation is a shorthand property for the various animation properties: animation-name, animation-duration, animation-iteration-count, animation-direction are used.

  6. nth-child(n) targets the element which is the nth child of its parent.

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

95.3%

✅ No caveats.

Box-sizing resetlayout

Resets the box-model so that widths and heights are not affected by their borders or padding.

CSS

html {
+

Demo

Explanation

Note: 1rem is usually 16px.

  1. @keyframes defines an animation that has two states, where the element changes opacity and is translated up on the 2D plane using transform: translateY().

  2. .bouncing-loader is the parent container of the bouncing circles and uses display: flex and justify-content: center to position them in the center.

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

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

  5. animation is a shorthand property for the various animation properties: animation-name, animation-duration, animation-iteration-count, animation-direction are used.

  6. nth-child(n) targets the element which is the nth child of its parent.

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

95.3%

✅ No caveats.

Box-sizing resetlayout

Resets the box-model so that widths and heights are not affected by their borders or padding.

CSS

html {
   box-sizing: border-box;
 }
 *,
@@ -149,18 +149,13 @@ li::before {
   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

95.3%

⚠️ Requires prefixes for full support.

Dynamic shadowvisual

Creates a shadow similar to box-shadow but based on the colors of the element itself.

HTML

<div class="dynamic-shadow-parent">
-  <div class="dynamic-shadow"></div>
-</div>
-

CSS

.dynamic-shadow-parent {
-  position: relative;
-  z-index: 1;
-}
-.dynamic-shadow {
+

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

95.3%

⚠️ Requires prefixes for full support.

Dynamic shadowvisual

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: '';
@@ -173,7 +168,7 @@ li::before {
   opacity: 0.7;
   z-index: -1;
 }
-

Demo

Explanation

The snippet requires a somewhat complex case of stacking contexts to get right, such that the pseudo-element will be positioned underneath the element itself while still being visible.

  1. position: relative on the parent establishes a Cartesian positioning context for child elements.
  2. z-index: 1 establishes a new stacking context.
  3. position: relative on the child establishes a positioning context for pseudo-elements.
  4. ::after defines a pseudo-element.
  5. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.
  6. width: 100% and height: 100% sizes the pseudo-element to fill its parent's dimensions, making it equal in size.
  7. background: inherit causes the pseudo-element to inherit the linear gradient specified on the element.
  8. top: 0.5rem offsets the pseudo-element down slightly from its parent.
  9. filter: blur(0.4rem) will blur the pseudo-element to create the appearance of a shadow underneath.
  10. opacity: 0.7 makes the pseudo-element partially transparent.
  11. z-index: -1 positions the pseudo-element behind the parent.

Browser support

91.7%

⚠️ Requires prefixes for full support.

Easing variablesanimation

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"></div>
+

Demo

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

91.7%

⚠️ Requires prefixes for full support.

Easing variablesanimation

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"></div>
 

CSS

:root {
   --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);
diff --git a/index.html b/index.html
index 89a5d54c0..096080923 100644
--- a/index.html
+++ b/index.html
@@ -779,19 +779,14 @@ in any specification.

Dynamic shadowvisual

Creates a shadow similar to box-shadow but based on the colors of the element itself.

-

HTML

<div class="dynamic-shadow-parent">
-  <div class="dynamic-shadow"></div>
-</div>
+            

HTML

<div class="dynamic-shadow"></div>
 
-

CSS

.dynamic-shadow-parent {
-  position: relative;
-  z-index: 1;
-}
-.dynamic-shadow {
+            

CSS

.dynamic-shadow {
   position: relative;
   width: 10rem;
   height: 10rem;
   background: linear-gradient(75deg, #6d78ff, #00ffb8);
+  z-index: 1;
 }
 .dynamic-shadow::after {
   content: '';
@@ -807,20 +802,15 @@ in any specification.

Demo

-
-
-
+

Explanation

-

The snippet requires a somewhat complex case of stacking contexts to get right, such that the pseudo-element will be positioned underneath the element itself while still being visible.

    -
  1. position: relative on the parent establishes a Cartesian positioning context for child elements.
  2. +
  3. position: relative on the element establishes a Cartesian positioning context for psuedo-elements.
  4. z-index: 1 establishes a new stacking context.
  5. -
  6. position: relative on the child establishes a positioning context for pseudo-elements.
  7. ::after defines a pseudo-element.
  8. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.
  9. width: 100% and height: 100% sizes the pseudo-element to fill its parent's dimensions, making it equal in size.
  10. @@ -847,7 +835,7 @@ in any specification.

  11. top: 0.5rem offsets the pseudo-element down slightly from its parent.
  12. filter: blur(0.4rem) will blur the pseudo-element to create the appearance of a shadow underneath.
  13. opacity: 0.7 makes the pseudo-element partially transparent.
  14. -
  15. z-index: -1 positions the pseudo-element behind the parent.
  16. +
  17. z-index: -1 positions the pseudo-element behind the parent but in front of the background.

Browser support

diff --git a/snippets/dynamic-shadow.md b/snippets/dynamic-shadow.md index 59b447275..e18b586a2 100644 --- a/snippets/dynamic-shadow.md +++ b/snippets/dynamic-shadow.md @@ -5,23 +5,18 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element #### HTML ```html -
-
-
+
``` #### CSS ```css -.dynamic-shadow-parent { - position: relative; - z-index: 1; -} .dynamic-shadow { position: relative; width: 10rem; height: 10rem; background: linear-gradient(75deg, #6d78ff, #00ffb8); + z-index: 1; } .dynamic-shadow::after { content: ''; @@ -39,21 +34,16 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element #### Demo
-
-
-
+