Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="card">
  <img src="https://gatoledo.com/proj-codepen/earth-bg.jpg" class="img-btn">
  <button id="play-video" class="video-play-button">
    <span></span>
  </button>
  <p>Earth orbit</p>
</div>

<div id="video-overlay" class="video-overlay">
  <a class="video-overlay-close">&times;</a>
</div>
              
            
!

CSS

              
                *
  box-sizing: border-box

body
  margin: 0
  height: 100vh
  background: url('https://gatoledo.com/proj-codepen/earth-bg.jpg')
  background-position-x: center
  background-repeat: no-repeat
  background-size: cover
  backdrop-filter: grayscale(0.5) blur(2px)

.card
  width: 50vw
  height: 28vw
  position: absolute
  inset: 0
  margin: auto
  transition: .2s ease-out
  &:hover
    transform: translate(0, -8px)
    transition: .2s ease
    animation-fill-mode: both
  @media (max-width: 767px)
    width: 75vw
    height: 45vw
  img
    width: 100%
    border-radius: 12px
    box-shadow: 5px 30px 70px -15px #111
  p
    position: absolute
    margin: 0
    font-family: sans-serif
    color: #fff
    padding: 10px 30px
    bottom: 25px
    background: rgba(0, 68, 255, 0.5)
    border-top-right-radius: 50px
    border-bottom-right-radius: 50px
    @media (max-width: 480px)
      font-size: 14px
      margin: 0 auto
      padding: 6px 15px
      bottom: -10px
      right: 0
      left: 0
      background: #0f46de
      border-top-right-radius: 0px
      border-bottom-right-radius: 12px
      border-bottom-left-radius: 12px
  .video-play-button
    position: absolute
    z-index: 10
    inset: 0
    margin: auto
    box-sizing: content-box
    display: block
    cursor: pointer
    width: 32px
    height: 44px
    border: none
    border-radius: 50%
    padding: 18px 20px 18px 28px

    &:before
      content: ""
      position: absolute
      z-index: 0
      inset: 0
      margin: auto
      display: block
      width: 80px
      height: 80px
      background: linear-gradient(45deg, rgba(253, 78, 11, 0.9) 15%, rgba(255, 0, 0, 0.95) 70%)
      border-radius: 50%
      -webkit-animation: pulse-border 1500ms ease-out infinite
      animation: pulse-border 1500ms ease-out infinite

    &:after
      content: ""
      position: absolute
      z-index: 1
      inset: 0
      margin: auto
      display: block
      width: 80px
      height: 80px
      background: linear-gradient(45deg, rgb(253, 78, 11) 15%, rgb(255, 0, 0) 70%)
      border-radius: 50%
      transition: all 200ms
      box-shadow: 0 2px 7px #131b49

    &:hover:after
      background-color: #da0528

.video-play-button 
  span
    display: block
    position: relative
    z-index: 3
    width: 0
    height: 0
    border-left: 30px solid #fff
    border-top: 18px solid transparent
    border-bottom: 18px solid transparent
    border-radius: 4px

@-webkit-keyframes pulse-border
  0%
    -webkit-transform: scale(1)
    transform: scale(1)
    opacity: 1

  100%
    -webkit-transform: scale(1.75)
    transform: scale(1.75)
    opacity: 0

@keyframes pulse-border
  0%
    -webkit-transform: scale(1)
    transform: scale(1)
    opacity: 1

  100%
    -webkit-transform: scale(1.75)
    transform: scale(1.75)
    opacity: 0

.video-overlay
  position: fixed
  z-index: -1
  inset: 0
  background: rgba(0, 0, 0, 0.55)
  opacity: 0
  transition: all ease 500ms
  &.open
    position: fixed
    z-index: 1000
    opacity: 1

.video-overlay-close
  position: absolute
  z-index: 1000
  top: 15px
  right: 20px
  font-size: 36px
  line-height: 1
  font-weight: 400
  color: #fff
  text-decoration: none
  cursor: pointer
  transition: all 200ms
  &:hover
    color: #fa183d

.video-overlay 
  iframe
    position: absolute
    inset: 0
    margin: auto
    width: 80vw
    height: 47vw
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.75)
    opacity: 0
    z-index: 1
    animation-name: fadeInUp
    -webkit-animation-name: fadeInUp
    animation-delay: 0.4s
    animation-duration: 0.5s
    animation-fill-mode: both
    -webkit-animation-duration: 0.5s
    -webkit-animation-fill-mode: both
    
@keyframes fadeInUp
  from
    transform: translate3d(0, 30px, 0)
  to
    transform: translate3d(0, 0, 0)
    opacity: 1
              
            
!

JS

              
                const player = document.querySelector("#play-video")
const videoOverlay = document.querySelector("#video-overlay")

player.addEventListener("click", function (e) {
  e.preventDefault();
  videoOverlay.classList.add("open")
  videoOverlay.innerHTML += '<iframe src="https://gatoledo.com/proj-codepen/earth.mp4" width="853" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>';
})

videoOverlay.addEventListener("click", function (e) {
  e.preventDefault();
  close_video();
});

document.addEventListener("keyup", function (e) {
  if (e.keyCode === 27) {
    close_video();
  }
});

function close_video() {
  videoOverlay.classList.remove("open")
  videoOverlay.querySelector("iframe").remove();
}

              
            
!
999px

Console