From 75b04e21baf313191f21a132358c973cf8b2766a Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 12 Jan 2019 14:03:37 +0200 Subject: [PATCH] Revert changes to index.html --- index.html | 1974 +++++++++++++++++++++------------------------------- 1 file changed, 802 insertions(+), 1172 deletions(-) diff --git a/index.html b/index.html index 041c02d18..d1910cd78 100644 --- a/index.html +++ b/index.html @@ -4,15 +4,23 @@ 30 Seconds of CSS - + + + + + + + + + + + - + @@ -101,20 +70,7 @@
- +

Bouncing loaderanimation

Creates a bouncing loader animation.

@@ -125,13 +81,9 @@ </div>

CSS

@keyframes bouncing-loader {
-  from {
-    opacity: 1;
-    transform: translateY(0);
-  }
   to {
     opacity: 0.1;
-    transform: translateY(-1rem);
+    transform: translate3d(0, -1rem, 0);
   }
 }
 .bouncing-loader {
@@ -161,51 +113,41 @@
                 
- +

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

    +

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

  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.

    +

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

    +

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

    +

    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.

    @@ -220,14 +162,12 @@

    Browser support

    - 95.3% + 93.4%

    ✅ No caveats.

    @@ -264,28 +204,23 @@
    border-box
    content-box
    - +

    Explanation

    1. box-sizing: border-box makes the addition of padding or borders not affect an element's width or height.
    2. @@ -294,152 +229,16 @@

      Browser support

      - 98.4% + 95.9%

      ✅ No caveats.

      -
      - New -

      Toggle switchvisualinteractivity

      -

      Creates a border animation on hover.

      -

      HTML

      <button class="button">Submit</button>
      -
      -

      CSS

      @import url(https://fonts.googleapis.com/css?family=BenchNine:700);
      -.button {
      -  background-color: #c47135;
      -  border: none;
      -  color: #ffffff;
      -  cursor: pointer;
      -  display: inline-block;
      -  font-family: 'BenchNine', Arial, sans-serif;
      -  font-size: 1em;
      -  font-size: 22px;
      -  line-height: 1em;
      -  margin: 15px 40px;
      -  outline: none;
      -  padding: 12px 40px 10px;
      -  position: relative;
      -  text-transform: uppercase;
      -  font-weight: 700;
      -}
      -.button:before,
      -.button:after {
      -  border-color: transparent;
      -  -webkit-transition: all 0.25s;
      -  transition: all 0.25s;
      -  border-style: solid;
      -  border-width: 0;
      -  content: '';
      -  height: 24px;
      -  position: absolute;
      -  width: 24px;
      -}
      -.button:before {
      -  border-color: #c47135;
      -  border-top-width: 2px;
      -  left: 0px;
      -  top: -5px;
      -}
      -.button:after {
      -  border-bottom-width: 2px;
      -  border-color: #c47135;
      -  bottom: -5px;
      -  right: 0px;
      -}
      -.button:hover,
      -.button.hover {
      -  background-color: #c47135;
      -}
      -.button:hover:before,
      -.button.hover:before,
      -.button:hover:after,
      -.button.hover:after {
      -  height: 100%;
      -  width: 100%;
      -}
      -
      -

      Demo

      -
      - -
      - -

      Explanation

      -

      This effect is uses before and after selectors to make the border full width on hover.

      -

      Browser support

      -
      -
      - 99+% -
      -
      -

      ✅ No caveats.

      - - - - -

      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.

      @@ -455,46 +254,43 @@
      - -

      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():

      + +

      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
      + height: 280px; + display: flex; + align-items: center; + justify-content: center; + color: #fff; + background: #222 url('https://image.ibb.co/fUL9nS/wolf.png') no-repeat; + background-position: calc(100% - 20px) calc(100% - 40px); +} +

      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. -
      5. 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.
      6. +
      7. 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

      - 94.9% + 93.0%

      ✅ No caveats.

      @@ -515,28 +311,25 @@
      - +

      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.

      +

      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

      - 95.5% + 93.7%

      ✅ No caveats.

      @@ -568,21 +361,19 @@
      float c
      - +

      Explanation

      1. .clearfix::after defines a pseudo-element.
      2. content: '' allows the pseudo-element to affect layout.
      3. -
      4. 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.
      5. +
      6. 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

      @@ -596,7 +387,8 @@

      Constant width to height ratiolayout

      -

      Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion (i.e., its width to height ratio remains constant).

      +

      Given an element of variable width, it will ensure its height remains proportionate in a responsive fashion + (i.e., its width to height ratio remains constant).

      HTML

      <div class="constant-width-to-height-ratio"></div>
       

      CSS

      .constant-width-to-height-ratio {
      @@ -618,26 +410,22 @@
                   
      - +

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

      +

      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

      @@ -688,47 +476,40 @@ li::before {
      - +

      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 in 0. This property can also be used to change its value to any specific number.

        +

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

        +

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

        +

        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.

        +

        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

      - 98.4% + 95.9%

      ✅ No caveats.

      @@ -738,9 +519,9 @@ li::before {

      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>
      +    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>
      @@ -766,52 +547,43 @@ li::before {
                   

      - 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? + 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

      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.

      +

      There are many other pseudo-elements that you can use to style scrollbars. For more info, visit the WebKit Blog.

      Browser support

      - 88.0% + 86.7%

      ⚠️ Scrollbar styling doesn't appear to be on any standards track.

      @@ -834,30 +606,25 @@ li::before {

      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

      - 84.9% + 82.5%

      ⚠️ Requires prefixes for full support and is not actually in any specification.

      @@ -885,21 +652,18 @@ in any specification.

      CSS is awesome!

      - +

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

      @@ -907,14 +671,12 @@ in any specification.

      Browser support

      - 88.0% + 87.6%

      ✅ No caveats.

      @@ -934,25 +696,21 @@ in any specification.

      You can select me.

      You can't select me!

      - +

      Explanation

      user-select: none specifies that the text cannot be selected.

      Browser support

      - 87.2% + 89.2%

      ⚠️ Requires prefixes for full support. ⚠️ This is not a secure method to prevent users from copying content.

      @@ -961,9 +719,7 @@ in any specification.

      Display table centeringlayout

      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 class="center"><span>Centered content</span></div>
       </div>
       

      CSS

      .container {
      @@ -985,28 +741,22 @@ in any specification.

      Demo

      -
      - Centered content -
      +
      Centered content
      - +

      Explanation

      1. display: table on '.center' allows the element to behave like a <table> HTML element.
      2. @@ -1024,9 +774,7 @@ in any specification.

        ✅ No caveats.

        @@ -1058,41 +806,33 @@ in any specification.

        - +

        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.

        +

        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% + 93.4%

        ⚠️ Requires prefixes for full support.

        @@ -1125,26 +865,23 @@ in any specification.

        - +

        Explanation

        1. position: relative on the element establishes a Cartesian positioning context for psuedo-elements.
        2. @@ -1161,21 +898,20 @@ in any specification.

          Browser support

          - 91.7% + 90.2%

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

          +

          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 {
          @@ -1218,57 +954,50 @@ in any specification.

          Hover
          - +

          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.

          +

          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

          - 88.0% + 87.6%

          ✅ No caveats.

          @@ -1289,29 +1018,27 @@ in any specification.

          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.

          +

          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.

          +

          The text color should be slightly faded to make it look like it's engraved/carved out + of the background.

          Browser support

          - 98.1% + 95.5%

          ✅ No caveats.

          @@ -1338,12 +1065,10 @@ in any specification.

          Item3

          - +

          Explanation

          1. display: flex enables flexbox.
          2. @@ -1353,24 +1078,77 @@ in any specification.

            Browser support

            - 98.1% + 95.5%

            ⚠️ Needs prefixes for full support.

            +
            +

            Fit image in containerlayoutvisual

            +

            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

            +
            +
            + 91.5% +
            +
            +

            ✅ No caveats.

            + + + + + +

            Flexbox centeringlayout

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

            HTML

            <div class="flexbox-centering"><div class="child">Centered content.</div></div>
             

            CSS

            .flexbox-centering {
               display: flex;
            @@ -1385,14 +1163,12 @@ in any specification.

            Centered content.
            - +

            Explanation

            1. display: flex enables flexbox.
            2. @@ -1402,14 +1178,12 @@ in any specification.

              Browser support

              - 98.1% + 95.5%

              ⚠️ Needs prefixes for full support.

              @@ -1429,30 +1203,27 @@ in any specification.

              Gradient 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. -
              4. webkit-background-clip: text clips the background with the text, filling the text with the gradient background as the color.
              5. +
              6. webkit-background-clip: text clips the background with the text, filling the text with + the gradient background as the color.

              Browser support

              - 91.5% + 90.1%

              ⚠️ Uses non-standard properties.

              @@ -1460,9 +1231,7 @@ in any specification.

              Grid centeringlayout

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

              HTML

              <div class="grid-centering"><div class="child">Centered content.</div></div>
               

              CSS

              .grid-centering {
                 display: grid;
              @@ -1477,14 +1246,12 @@ in any specification.

              Centered content.
              - +

              Explanation

              1. display: grid enables grid.
              2. @@ -1494,21 +1261,20 @@ in any specification.

                Browser support

                - 87.6% + 88.3%

                ✅ No caveats.

                Hairline bordervisual

                -

                Gives an element a border equal to 1 native device pixel in width, which can look very sharp and crisp.

                +

                Gives an element a border equal to 1 native device pixel in width, which can look + very sharp and crisp.

                HTML

                <div class="hairline-border">text</div>
                 

                CSS

                .hairline-border {
                @@ -1534,45 +1300,34 @@ in any specification.

                text
                - +

                Explanation

                1. box-shadow, when only using spread, adds a pseudo-border which can use subpixels*.
                2. -
                3. 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.
                4. +
                5. 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

                - 95.5% + 93.7%

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

                @@ -1607,40 +1362,37 @@ el.style.setProperty('--max-height', height + 'px')
                content
                - - + +

                Explanation

                CSS
                1. transition: max-height: 0.5s cubic-bezier(...) specifies that changes to max-height should be transitioned over 0.5 seconds, using an ease-out-quint timing function.
                2. overflow: hidden prevents the contents of the hidden element from overflowing its container.
                3. max-height: 0 specifies that the element has no height initially.
                4. -
                5. .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.
                6. +
                7. .target:hover > .el specifies that when the parent is hovered over, target a child .el within + it and use the --max-height variable which was defined by JavaScript.
                JavaScript
                  -
                1. el.scrollHeight is the height of the element including overflow, which will change dynamically based on the content of the element.
                2. +
                3. el.scrollHeight is the height of the element including overflow, which will change dynamically + based on the content of the element.
                4. 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

                - 88.0% + 87.6%

                @@ -1651,12 +1403,71 @@ el.style.setProperty('--max-height', height + 'px')

                + + + +
                +

                Hover Shadow Box Animationanimation

                +

                Creates a shadow box around the text whern 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

                +
                +

                Box it!

                +
                + +

                Explanation

                +
                  +
                1. display: inline-block to set width and length for p element thus making it an inline-block.
                2. +
                3. 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.
                4. +
                5. box-shadow: to set up the box.
                6. +
                7. transparent to make box transparent.
                8. +
                9. transition-property to enable transitions for both box-shadow and transform.
                10. +
                11. :hover to activate whole css when hovering is done until active.
                12. +
                13. transform: scale(1.2) to change the scale, magnifying the text.
                14. +
                +

                Browser Support

                +
                +
                + 93.3% +
                +
                +

                ✅ No caveats.

                + @@ -1664,11 +1475,7 @@ el.style.setProperty('--max-height', height + 'px')

                Hover underline animationanimation

                Creates an animated underline effect when the text is hovered over.

                -

                - Credit: - https://flatuicolors.com/ - -

                +

                Credit: https://flatuicolors.com/

                HTML

                <p class="hover-underline-animation">Hover this text to see the effect!</p>
                 

                CSS

                .hover-underline-animation {
                @@ -1697,191 +1504,57 @@ el.style.setProperty('--max-height', height + 'px')
                             

                Hover this text to see the effect!

                - +

                Explanation

                  -
                1. 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).
                2. +
                3. 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).
                4. position: relative on the element establishes a Cartesian positioning context for pseudo-elements.
                5. ::after defines a pseudo-element.
                6. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.
                7. width: 100% ensures the pseudo-element spans the entire width of the text block.
                8. transform: scaleX(0) initially scales the pseudo element to 0 so it has no width and is not visible.
                9. bottom: 0 and left: 0 position it to the bottom left of the block.
                10. -
                11. transition: transform 0.25s ease-out means changes to transform will be transitioned over 0.25 seconds with an ease-out timing function.
                12. +
                13. transition: transform 0.25s ease-out means changes to transform will be transitioned over 0.25 seconds + with an ease-out timing function.
                14. transform-origin: bottom right means the transform anchor point is positioned at the bottom right of the block.
                15. -
                16. :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.
                17. +
                18. :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

                - 95.4% + 93.5%

                ✅ No caveats.

                - New -

                Icon Border Animationvisualinteractivity

                -

                Creates a border animation on hover.

                -

                HTML

                <a href="#" class="button ion-ios-star-outline"></a>
                -
                -

                CSS

                @import url(https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css);
                -.button {
                -  position: relative;
                -  overflow: hidden;
                -  font-size: 40px;
                -  color: rgba(255, 255, 255, 0.8);
                -  margin: 40px;
                -  padding: 3px;
                -  display: inline-block;
                -  text-align: center;
                -  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.6);
                -  text-decoration: none;
                -  -webkit-box-sizing: border-box;
                -  box-sizing: border-box;
                -}
                -.button::before {
                -  background-color: #2b2b2b;
                -  width: 75px;
                -  height: 75px;
                -  line-height: 75px;
                -}
                -.button:after {
                -  position: absolute;
                -  top: 0;
                -  bottom: 0;
                -  left: 0;
                -  right: 0;
                -  background-color: #f39c12;
                -  content: '';
                -  z-index: -1;
                -  display: inline-block;
                -  -webkit-transform: rotate(-45deg) scale(1.5) translate(0%, -100%);
                -  transform: rotate(-45deg) scale(1.5) translate(0%, -100%);
                -}
                -.button:before,
                -.button:after {
                -  -webkit-transition: all 0.4s ease-in-out;
                -  transition: all 0.4s ease-in-out;
                -}
                -.button:hover,
                -.button:active,
                -.button.hover {
                -  color: #ffffff;
                -}
                -.button:hover:after,
                -.button:active:after,
                -.button.hover:after {
                -  -webkit-transform: rotate(-45deg) scale(1.5) translate(0%, 0%);
                -  transform: rotate(-45deg) scale(1.5) translate(0%, 0%);
                -}
                -
                -

                Demo

                -
                - -
                - -

                Explanation

                -

                This effect is uses before and after selectors to make the border full width on hover.

                -

                Browser support

                -
                -
                - 99+% -
                -
                -

                ✅ No caveats.

                - - - - -
                -
                - New

                Last item with remaining available heightlayout

                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">
                @@ -1913,22 +1586,18 @@ body {
                                 
                Div 3
                - +

                Explanation

                1. height: 100% set the height of container as viewport height.
                2. @@ -1940,14 +1609,12 @@ body {

                  Browser support

                  - 98.1% + 95.5%

                  ⚠️ Needs prefixes for full support.

                  @@ -1957,14 +1624,8 @@ body {

                  Mouse cursor gradient trackingvisualinteractivity

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

                  Credit: Tobias Reich

                  +

                  HTML

                  <button class="mouse-cursor-gradient-tracking"><span>Hover me</span></button>
                   

                  CSS

                  .mouse-cursor-gradient-tracking {
                     position: relative;
                  @@ -2005,59 +1666,48 @@ btn.onmousemove = function(e) {
                   }
                   

                  Demo

                  -
                  - -
                  - - +
                  + +

                  Explanation

                  TODO

                  Browser support

                  - 88.0% + 87.6%

                  @@ -2065,9 +1715,7 @@ btn.onmousemove = function(e) { ⚠️ Requires JavaScript.

                  @@ -2106,48 +1754,38 @@ li:not(:last-child) {
                3. Four
                4. - +

                  Explanation

                  -

                  li:not(:last-child) specifies that the styles should apply to all li elements except the :last-child.

                  +

                  li:not(:last-child) specifies that the styles should apply to all li elements except + the :last-child.

                  Browser support

                  - 98.4% + 95.9%

                  ✅ No caveats.

                  Offscreenlayoutvisual

                  -

                  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.

                  +

                  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>
                  +  Learn More <span class="offscreen"> about pants</span>
                   </a>
                   

                  CSS

                  .offscreen {
                  @@ -2162,24 +1800,19 @@ li:not(:last-child) {
                   }
                   

                  Demo

                  - - + +

                  Explanation

                  1. Remove all borders.
                  2. @@ -2199,9 +1832,7 @@ li:not(:last-child) {

                    ✅ No caveats.

                    (Although clip technically has been depreciated, the newer clip-path currently has very limited browser support.)

                    @@ -2211,13 +1842,13 @@ li:not(:last-child) {

                    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>
                    +    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>
                    @@ -2250,47 +1881,45 @@ li:not(:last-child) {
                                 
                    - 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? -
                    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? + 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?
                    + 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

                    1. position: relative on the parent establishes a Cartesian positioning context for pseudo-elements.
                    2. ::after defines a pseudo element.
                    3. -
                    4. background-image: linear-gradient(...) adds a linear gradient that fades from transparent to white (top to bottom).
                    5. +
                    6. background-image: linear-gradient(...) adds a linear gradient that fades from transparent to white + (top to bottom).
                    7. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.
                    8. -
                    9. width: 240px matches the size of the scrolling element (which is a child of the parent that has the pseudo element).
                    10. +
                    11. width: 240px matches the size of the scrolling element (which is a child of the parent that has + the pseudo element).
                    12. height: 25px is the height of the fading gradient pseudo-element, which should be kept relatively small.
                    13. bottom: 0 positions the pseudo-element at the bottom of the parent.
                    14. pointer-events: none specifies that the pseudo-element cannot be a target of mouse events, allowing text behind it to still be selectable/interactive.
                    15. @@ -2298,14 +1927,12 @@ li:not(:last-child) {

                      Browser support

                      - 95.4% + 93.5%

                      ✅ No caveats.

                      @@ -2313,11 +1940,7 @@ li:not(:last-child) {

                      Popout menuinteractivity

                      Reveals an interactive popout menu on hover and focus.

                      -

                      HTML

                      <div class="reference" tabindex="0">
                      -  <div class="popout-menu">
                      -    Popout menu
                      -  </div>
                      -</div>
                      +            

                      HTML

                      <div class="reference" tabindex="0"><div class="popout-menu">Popout menu</div></div>
                       

                      CSS

                      .reference {
                         position: relative;
                      @@ -2342,40 +1965,33 @@ li:not(:last-child) {
                                   

                      Demo

                      -
                      - Popout menu -
                      +
                      Popout menu
                      - +

                      Explanation

                      1. position: relative on the reference parent establishes a Cartesian positioning context for its child.
                      2. position: absolute takes the popout menu out of the flow of the document and positions it in relation to the parent.
                      3. left: 100% moves the the popout menu 100% of its parent's width from the left.
                      4. visibility: hidden hides the popout menu initially and allows for transitions (unlike display: none).
                      5. -
                      6. .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.
                      7. +
                      8. .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.
                      9. .reference:focus > .popout-menu means that when .reference is focused, the popout would be shown.
                      10. .reference:focus-within > .popout-menu ensures that the popout is shown when the focus is within the reference.
                      @@ -2391,8 +2007,8 @@ li:not(:last-child) {

                      Pretty text underlinevisual

                      -

                      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.

                      +

                      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 {
                      @@ -2416,47 +2032,44 @@ li:not(:last-child) {
                                   

                      Pretty text underline without clipping descending letters.

                      - +

                      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. -
                      3. background-image: linear-gradient(...) creates a 90deg gradient using the text color (currentColor).
                      4. -
                      5. 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.
                      6. -
                      7. The ::selection pseudo selector rule ensures the text shadow does not interfere with text selection. -
                      8. +
                      9. 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.
                      10. +
                      11. background-image: linear-gradient(...) creates a 90deg gradient using the + text color (currentColor).
                      12. +
                      13. 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.
                      14. +
                      15. The ::selection pseudo selector rule ensures the text shadow does not interfere with text + selection.

                      Browser support

                      - 95.4% + 93.5%

                      ✅ No caveats.

                      @@ -2466,7 +2079,11 @@ li:not(:last-child) {

                      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>
                      +  <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 {
                      @@ -2477,27 +2094,27 @@ li:not(:last-child) {
                                   
                      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?

                      +

                      + 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

                      - 88.3% + 87.2%

                      ⚠️ MS Edge status is under consideration.

                      @@ -2525,28 +2142,23 @@ li:not(:last-child) {
                      - +

                      Explanation

                      1. position: relative on the element establishes a Cartesian positioning context for pseudo elements.
                      2. ::after defines a pseudo element.
                      3. -
                      4. 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.
                      5. +
                      6. 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.
                      7. position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.
                      8. width: 100% ensures the element stretches the entire width of its parent.
                      9. height: 12px is the same height as the shape.
                      10. @@ -2555,14 +2167,12 @@ li:not(:last-child) {

                        Browser support

                        - 98.3% + 95.7%

                        ✅ No caveats.

                        @@ -2571,12 +2181,8 @@ li:not(:last-child) {

                        Sibling fadeinteractivity

                        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>
                        +  <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 {
                        @@ -2590,42 +2196,32 @@ li:not(:last-child) {
                                     

                        Demo

                        - Item 1 - Item 2 - Item 3 - Item 4 - Item 5 - Item 6 + Item 1 Item 2 Item 3 Item 4 + Item 5 Item 6
                        - +

                        Explanation

                        1. transition: opacity 0.2s specifies that changes to opacity will be transitioned over 0.2 seconds.
                        2. -
                        3. .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.
                        4. +
                        5. .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

                        - 95.4% + 93.5%

                        ✅ No caveats.

                        @@ -2644,13 +2240,12 @@ li:not(:last-child) {

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

                        +

                        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. @@ -2673,11 +2268,9 @@ li:not(:last-child) {
                      - New

                      Toggle switchvisualinteractivity

                      Creates a toggle switch with CSS only.

                      -

                      HTML

                      <input type="checkbox" id="toggle" class="offscreen" />
                      -<label for="toggle" class="switch"></label>
                      +            

                      HTML

                      <input type="checkbox" id="toggle" class="offscreen" /> <label for="toggle" class="switch"></label>
                       

                      CSS

                      .switch {
                         position: relative;
                      @@ -2711,10 +2304,7 @@ input[type='checkbox']:checked + .switch {
                       }
                       

                      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.

                      +

                      This effect is styling only the <label> element to look like a toggle switch, and hiding the actual <input> checkbox by positioning it offscreen. When clicking the label associated with the <input> element, it sets the <input> checkbox into the :checked state.

                      1. The for attribute associates the <label> with the appropriate <input> checkbox element by its id.
                      2. .switch::after defines a pseudo-element for the <label> to create the circular knob.
                      3. input[type='checkbox']:checked + .switch::after targets the <label>'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. -
                      7. .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.
                      8. -
                      9. 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.
                      10. +
                      11. .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.
                      12. +
                      13. 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

                      - 95.5% + 93.7%

                      ⚠️ Requires prefixes for full support.

                      @@ -2778,11 +2365,8 @@ input[type='checkbox']:checked + .switch {

                      Transform centeringlayout

                      -

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

                      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;
                      @@ -2834,9 +2418,7 @@ input[type='checkbox']:checked + .switch {
                                   

                      ⚠️ Requires prefix for full support.

                      @@ -2868,10 +2450,10 @@ input[type='checkbox']:checked + .switch { }

                      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.

                      +

                      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

                      @@ -2909,26 +2491,74 @@ input[type='checkbox']:checked + .switch {

                      Explanation

                        -
                      1. overflow: hidden prevents the text from overflowing its dimensions (for a block, 100% width and auto height).
                      2. +
                      3. overflow: hidden prevents the text from overflowing its dimensions + (for a block, 100% width and auto height).
                      4. white-space: nowrap prevents the text from exceeding one line in height.
                      5. -
                      6. text-overflow: ellipsis makes it so that if the text exceeds its dimensions, it will end with an ellipsis.
                      7. +
                      8. text-overflow: ellipsis makes it so that if the text exceeds its dimensions, it + will end with an ellipsis.
                      9. width: 200px; ensures the element has a dimension, to know when to get ellipsis

                      Browser support

                      - 98.4% + 95.8%

                      ⚠️ Only works for single line elements.

                      +
                      +

                      Zebra striped listvisual

                      +

                      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

                      +
                        +
                      1. Use the :nth-child(odd) or :nth-child(even) pseudo-class to apply a different background color to elements that match based on their position in a group of siblings.
                      2. +
                      +

                      Note that you can use it to apply different styles to other HTML elements like div, tr, p, ol, etc.

                      +

                      Browser support

                      +
                      +
                      + 95.9% +
                      +
                      +

                      ✅ No caveats.

                      +

                      https://caniuse.com/#feat=css-sel3

                      + + + + +