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="background"></div>
  <div class="some-div">
  <div class="some-box">
    <br><br><br>
    <h1> 🌠 Prism Particle Parallax</h1>
    <br> 전경과 원경이 나뉘어 있습니다. <br>
    The layers are separated into<br>foreground and background.
  </div>
</div>
<!-- 코드펜 디스플레이용 여기까지-->
<div class="background-effect-prism">
</div>
<div class="background-effect-prism-back">
</div>
  
              
            
!

CSS

              
                /* 코드펜 디스플레이용 */
@font-face {
    font-family: 'ClimateCrisisKR-1979';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2212@1.0/ClimateCrisisKR-1979.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}
body {
  overflow:hidden;
}
.background {
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: url('https://images.unsplash.com/photo-1542272201-b1ca555f8505?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1974&q=80');
  position:absolute;
  overflow:hidden;
  filter: blur(3px);
}
.some-div {
  font-family: ClimateCrisisKR-1979;
  color:white;
  text-shadow:0px 0px 4px rgba(0,0,0,0.45);
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  position:relative;
  display:flex;
  justify-content: center;
  align-items: center;
  overflow:hidden;
  z-index: 1;
}
.some-box {
  width: 500px;
  height: 300px;
  display: block;
  margin: 0 auto;
  position: absolute;
  background: linear-gradient(120deg, rgba(255,255,255,0.8), rgba(255,255,255,0.1));
  box-shadow: 0px 0px 20px white inset, 0px 0px 30px rgba(0,0,0,0.3);
  border: 1px solid white;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  text-align: center;
}
/* 코드펜 디스플레이용 여기까지 */

/* 전경 레이어 */
.background-effect-prism {
			width: 100vw; 
			height: 100vh; 
			position:fixed; 
			top:0;
			left:0;
			pointer-events:none;
      z-index: 2;
		}
/* 원경 레이어 */
.background-effect-prism-back {
			width: 100vw; 
			height: 100vh; 
			position:fixed; 
			top:0;
			left:0;
			pointer-events:none;
      z-index: 0;
		}
/* 파티클 */
    .particle {
      position: absolute;
      width: 50px;
      height: 50px;
      display: block;
      border-radius: 100%;
      opacity: 0;
      animation-iteration-count: infinite;
      box-shadow: 10px -5px 3px rgba(255,255,255,0.2);
    }

    @keyframes spark1 {
      0% {opacity: 0;}
      30% {opacity: 1;}
      31% {opacity: 0;}
      32% {opacity: 1;}
      33% {opacity: 0;}
      34% {opacity: 1;}
      35% {opacity: 0;}
      70% {opacity: 1;}
      71% {opacity: 0;}
      90% {opacity: 1;}
      100% {opacity: 0;}
    }

    @keyframes spark2 {
      0% {opacity: 0;}
      70% {opacity: 1;}
      71% {opacity: 0;}
      90% {opacity: 1;}
      100% {opacity: 0;}
    }

    @keyframes sparkmove1 {
      0% {
        translate: -0px 0px;
      filter: blur(4px);}
      100% {translate: -900px 1200px;
      filter: blur(6px);}
    }

    @keyframes sparkmove2 {
      0% {
        translate: 0px 0px;
      filter: blur(1px);}
      100% {translate: -600px 800px;
      filter: blur(3px);}
    }

    /* 전경 */

    .background-effect-prism .particle:nth-child(n) {
      animation-name: spark1, sparkmove1;
      animation-duration: 20s;
      scale:200%;
    }
    .distance1-p {
    }

    .distance2-p {
    }

    /* 원경 */
 .background-effect-prism-back .particle:nth-child(n) {
      animation-name: spark2, sparkmove2;
      animation-duration: 40s;
      scale: 100%;
    }

              
            
!

JS

              
                // i < 100 <=이 숫자로 갯수 조정. 20의 배수를 추천합니다
for (let i = 0; i < 40; i++) {
        var particleDiv = document.createElement('div');
        var z = Math.floor(Math.random() * 4);
        var color = '';
        if (z == 0){
            color = '#F8E0EC';
        } else if (z == 1){
            color = '#CED8F6';
        } else if (z == 2){
            color = '#F5ECCE';
        } else if (z == 3){
            color = '#E6F8E0';
        }
        var gradient = "background: linear-gradient(45deg, " + color + ", rgba(255, 222, 222, 0.253));";
        var x = Math.floor(Math.random() * 120) - 40;
        var y = Math.floor(Math.random() * 120) - 40;
        if (i % 2 == 0){
          particleDiv.setAttribute("class", "particle distance1-p");
          particleDiv.setAttribute("style", "top: " + x + "vh; right: " + y + "vw;" + gradient + " animation-delay: " + i % 20 + "s;");
        } else {
          particleDiv.setAttribute("class", "particle distance2-p");
          particleDiv.setAttribute("style", "top: " + x + "vh; right: " + y + "vw;" + gradient + " animation-delay: " + i % 20 + "s;");
        }
  if(i % 2 == 0){
    document.querySelector('.background-effect-prism').appendChild(particleDiv);
  }
  else {
    document.querySelector('.background-effect-prism-back').appendChild(particleDiv);
  }
        
    }

	    $('body').ready(function() {
	    const movement = e =>{
		  var amountMovedX = (e.clientX * -0.43 / 6);
		  var amountMovedY = (e.clientY * -0.43 / 6);
      var amountMovedX2 = (e.clientX * -0.1 / 6);
		  var amountMovedY2 = (e.clientY * -0.1 / 6);
       $('.distance1-p').css('transform', 'translate3d(' + amountMovedX +'px, '+amountMovedY+ 'px, 0px)');
       $('.distance2-p').css('transform', 'translate3d(' + amountMovedX2 +'px, '+amountMovedY2+ 'px, 0px)');
	}
    
	$('body')[0].addEventListener('mousemove', movement);
        
      });

              
            
!
999px

Console