Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>CSS Overlay Effects</h1>
<a class="back" href="https://html-plus.in.ua/methods-create-overlay-layer">← Посмотреть статью</a>

<div class="overlay-trigger">
  <button>Overlay #01</button>
  <button>Overlay #02</button>
  <button>Overlay #03</button>
  <button>Overlay #04</button>
  <button>Overlay #05</button>
  <button>Overlay #06</button>
  <button>Overlay #07</button>
  <button>Overlay #08</button>
  <button>Overlay #09</button>
  <button>Overlay #10</button>
</div>

<button class="overlay-close">Close Overlay</button>

<div class="overlay overlay01"></div>
<div class="overlay overlay02"></div>
<div class="overlay overlay03"></div>
<div class="overlay overlay04"></div>
<div class="overlay overlay05"></div>
<div class="overlay overlay06"></div>
<div class="overlay overlay07"></div>
<div class="overlay overlay08"></div>
<div class="overlay overlay09"></div>
<div class="overlay overlay10">
  <div></div>
  <div></div>
  <div></div>
</div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
}
body {
  background: #fff;
  color: #222;
  font-family: 'Open Sans', sans-serif;
  font-weight: 300;
}
.back {
  position: absolute;
  top: 2em;
  right: 2em;
  z-index: 100;
  color: #222;
  text-decoration: none;
  transition: color .3s;
}
.back:hover {
  color: #aaa;
}
h1 {
  padding: 2em 0;
  font-size: 48px;
  font-weight: 300;
  text-align: center;
}

.overlay-trigger {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 840px;
  margin: 0 auto;
  padding: 0 20px;
}
.overlay-trigger button {
  display: block;
  margin: 1em;
  padding: 1em 2.5em;
  background: #222;
  border: 1px solid #222;
  border-radius: 4px;
  color: #fff;
  font-size: 16px;
  text-align: center;
  cursor: pointer;
  transition: .2s ease-in-out;
}
.overlay-trigger button:hover {
  background: transparent;
  color: #222;
}
.overlay-close {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10;
  padding: 1em 2.5em;
  background: #fff;
  border: 1px solid #fff;
  border-radius: 4px;
  color: #222;
  font-size: 16px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: .2s ease-in-out;
  transform: translate(-50%, -50%);
}
.overlay-close.is-open {
  opacity: 1;
  visibility: visible;
}
.overlay-close:hover {
  background: transparent;
  color: #fff;
}

.overlay01 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
}
.overlay01.is-open {
  opacity: 1;
  visibility: visible;
}

.overlay02 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
  transform: scale(.2);
}
.overlay02.is-open {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.overlay03 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
  transform: scaleY(0);
}
.overlay03.is-open {
  opacity: 1;
  visibility: visible;
  transform: scaleY(1);
}

.overlay04 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
  transform: translateY(-100%);
}
.overlay04.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.overlay05 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
  transform: translateX(-100%);
}
.overlay05.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.overlay06 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
  animation: .3s linear overlay06-close;
}
.overlay06.is-open {
  opacity: 1;
  visibility: visible;
  animation: .3s linear overlay06-open;
}
@keyframes overlay06-open {
  0% {
    transform: scaleY(0);
    transform-origin: top;
  }
  100% {
    transform: scaleY(1);
    transform-origin: top;
  }
}
@keyframes overlay06-close {
  0% {
    transform: scaleY(1);
    transform-origin: bottom;
  }
  100% {
    transform: scaleY(0);
    transform-origin: bottom;
  }
}

.overlay07 {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
  animation: .3s linear overlay07-close;
}
.overlay07.is-open {
  opacity: 1;
  visibility: visible;
  animation: .3s linear overlay07-open;
}
@keyframes overlay07-open {
  0% {
    transform: scaleX(0);
    transform-origin: left;
  }
  100% {
    transform: scaleX(1);
    transform-origin: left;
  }
}
@keyframes overlay07-close {
  0% {
    transform: scaleX(1);
    transform-origin: right;
  }
  100% {
    transform: scaleX(0);
    transform-origin: right;
  }
}

.overlay08,
.overlay08::before,
.overlay08::after {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  transition: .3s linear;
}
.overlay08 {
  opacity: 0;
  visibility: hidden;
}
.overlay08::before,
.overlay08::after {
  content: '';
  background: rgba(0, 0, 0, .45);
}
.overlay08::before {
  transform: translateY(-100%);
}
.overlay08::after {
  transform: translateY(100%);
}
.overlay08.is-open {
  opacity: 1;
  visibility: visible;
}
.overlay08.is-open::before,
.overlay08.is-open::after {
  transform: translateY(0);
}

.overlay09,
.overlay09::before,
.overlay09::after {
  position: fixed;
  top: 0;
  z-index: 2;
  height: 100%;
}
.overlay09 {
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transition: .3s linear;
}
.overlay09::before,
.overlay09::after {
  left: 50%;
  content: '';
  width: 200%;
  margin-left: -100%;
  background: rgba(0, 0, 0, .45);
  transform: skewX(-30deg) translateX(-100%);
  transition: transform .3s linear .3s;
}
.overlay09.is-open {
  opacity: 1;
  visibility: visible;
}
.overlay09.is-open::before {
  transform: skewX(-30deg) translateX(0);
  transition: transform .3s linear;
}
.overlay09.is-open::after {
  transform: skewX(-30deg) translateX(0);
  transition: transform .3s linear .15s;
}

.overlay10 {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: .6s linear .6s;
}
.overlay10 div::before,
.overlay10 div::after {
  position: fixed;
  left: 0;
  content: '';
  width: 100%;
  height: calc(100% / 6);
  background: rgba(0, 0, 0, .7);
  transform: rotateX(-270deg);
  transition: .3s linear;
}
.overlay10 div:nth-child(1)::before {
  top: 0;
}
.overlay10 div:nth-child(1)::after {
  top: calc(100% / 6);
  transition-delay: .1s;
}
.overlay10 div:nth-child(2)::before {
  top: calc(100% / 6 * 2);
  transition-delay: .2s;
}
.overlay10 div:nth-child(2)::after {
  top: calc(100% / 6 * 3);
  transition-delay: .3s;
}
.overlay10 div:nth-child(3)::before {
  top: calc(100% / 6 * 4);
  transition-delay: .4s;
}
.overlay10 div:nth-child(3)::after {
  bottom: 0;
  transition-delay: .5s;
}
.overlay10.is-open {
  opacity: 1;
  visibility: visible;
  transition: .6s linear;
}
.overlay10.is-open div::before,
.overlay10.is-open div::after {
  transform: rotateX(0);
}
              
            
!

JS

              
                //Forked by https://codepen.io/nxworld/pen/MvJQQy
$(function() {
  var $overlay = $('.overlay'),
      $overlayTrigger = $('.overlay-trigger button'),
      $overlayClose = $('.overlay-close'),
      openClass = 'is-open';

  $overlayTrigger.on('click', function() {
    var num = ('0' + ($(this).index() + 1)).slice(-2);
    $('.overlay' + num).addClass(openClass);
    $overlayClose.addClass(openClass);
  });

  $overlayClose.on('click', function() {
    $overlayClose.removeClass(openClass);
    $overlay.removeClass(openClass);
  });
});
              
            
!
999px

Console