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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                main
  .wave 
  .wave
  .wave
footer
.social-links
  a.social-link.social-link--twitter(href="https://twitter.com/jh3yy" target="_blank" rel="noopener noreferrer" title="Catch me on Twitter")
    svg(role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg")
      title Twitter icon
      path(d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z")
              
            
!

CSS

              
                *
  box-sizing border-box

:root
  --wave white
  --bg hsl(280, 30%, 30%)

body
  min-height 100vh
  display flex
  align-items center
  flex-direction column
  justify-content center

main
  background var(--bg)
  flex 1
  width 100vw
  position relative
  overflow hidden

footer
  background var(--wave)
  flex 1

.wave
  animation wave calc(var(--speed, 0) * 1s) infinite linear
  background-image url("https://assets.codepen.io/605876/wave--infinite.svg")
  background-size 50% 100%
  bottom -5%
  height calc(var(--height, 0) * 1vh)
  left 0
  opacity var(--opacity)
  position absolute
  right 0
  width calc(var(--width, 0) * 1vw)

  @media(max-width 480px)
    height calc(var(--height, 0) * 0.75vh)


@keyframes wave
  to
    transform translate(-50%, 0)


.social-links
  width 44px
  position fixed
  left 1rem
  bottom 1rem

  > a + a
    margin-top 0.5rem

.social-link
  height 44px
  width 44px
  display inline-block

  &--twitter
    --saturation 49%
    transition fill 0.2s
    display flex
    align-items center
    justify-content center
    path
      fill 'hsl(203, %s, 53%)' % var(--saturation)
    &:hover
      --saturation 89%



  img, svg
    height 60%
    width 60%
              
            
!

JS

              
                import { GUI } from 'https://cdn.skypack.dev/dat.gui'

const WAVES = document.querySelectorAll('.wave')
const CONFIG = [
  {
    speed: 30,
    opacity: 0.3,
    height: 12,
    width: 800,
  },
  {
    speed: 45,
    opacity: 0.6,
    height: 12,
    width: 800,
  },
  {
    speed: 15,
    opacity: 1,
    height: 6,
    width: 400,
  },
]
const UTILS = {
  copy: () => {
    const el = document.createElement('textarea')
    el.value = grabCSS()
    el.height = el.width = 0
    document.body.appendChild(el)
    el.select()
    document.execCommand('copy')
    document.body.removeChild(el)
    alert('CSS Saved To Clipboard!')
  }
}

const BG = {
  value: '#543663',
}

const updateWave = index => () => {
  for (const key of Object.keys(CONFIG[index])) {
    WAVES[index].style.setProperty(`--${key}`, CONFIG[index][key])
  }
}

WAVES.forEach((_, index) => updateWave(index)())

const grabCSS = () => `
.wave {
  animation: wave calc(var(--speed, 0) * 1s) infinite linear;
  background-image: url("https://assets.codepen.io/605876/wave--infinite.svg");
  background-size: 50% 100%;
  bottom: -5%;
  height: calc(var(--height, 0) * 1vh);
  left: 0;
  opacity: var(--opacity);
  position: absolute;
  right: 0;
  width: calc(var(--width, 0) * 1vw);
}
@keyframes wave {
  to {
    transform: translate(-50%, 0);
  }
}
.wave:nth-of-type(1) {
  --height: ${CONFIG[0].height};
  --opacity: ${CONFIG[0].opacity};
  --speed: ${CONFIG[0].speed};
  --width: ${CONFIG[0].width};
}
.wave:nth-of-type(2) {
  --height: ${CONFIG[1].height};
  --opacity: ${CONFIG[1].opacity};
  --speed: ${CONFIG[1].speed};
  --width: ${CONFIG[1].width};
}
.wave:nth-of-type(3) {
  --height: ${CONFIG[2].height};
  --opacity: ${CONFIG[2].opacity};
  --speed: ${CONFIG[2].speed};
  --width: ${CONFIG[2].width};
}
`


const CONTROLLER = new GUI({
  width: 300
})
WAVES.forEach((_, index) => {
  const WAVE = CONTROLLER.addFolder(`Wave ${index + 1}`)
  WAVE.add(CONFIG[index], 'speed', 0, 100, 0.1)
    .name('Speed')
    .onChange(updateWave(index))
  WAVE.add(CONFIG[index], 'opacity', 0.1, 1, 0.1)
    .name('Opacity')
    .onChange(updateWave(index))
  WAVE.add(CONFIG[index], 'height', 5, 50, 1)
    .name('Height')
    .onChange(updateWave(index))
  WAVE.add(CONFIG[index], 'width', 200, 1000, 100)
    .name('Width')
    .onChange(updateWave(index))
})
CONTROLLER.addColor(BG, 'value').name('Background Color').onChange(() =>
  document.documentElement.style.setProperty('--bg', BG.value)
)
CONTROLLER.add(UTILS, 'copy').name('Copy CSS')

              
            
!
999px

Console