123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .container
  .window
  .raindrops
    .borders
      - (1..100).each do
        .border
    .drops
      - (1..100).each do
        .raindrop
            
          
!
            
              // our background image.
// will be used for the window as well as
// the raindrops themselves
$image: 'https://i.imgur.com/xQdYC7x.jpg';

// container width and height.
// 100vw/vh so it fills the entire window
$width:100vw;
$height:100vh;

//number of raindrops
$raindrops:100;

body{
  background:#222;
}
.container{
  position:relative;
  width:$width;
  height:$height;
  overflow:hidden;
}
.window{
  position:absolute;
  width:$width;
  height:$height;
  background:url($image);
  background-size:cover;
  background-position:50%;
  filter:blur(10px);
}
// set all the containers to
// position:absolute, since 
// they will overlap
.raindrops,
.borders,
.drops{
  position:absolute;
}

// little brightness filter so our raindrops look shiny
.drops{
  filter:brightness(1.2);
}

// general settings for all the 
// raindrops and borders
.raindrop{
	position:absolute;
  border-radius:100%;
	background-image:url($image);
	background-size:$width*0.05 $height*0.05;
  background-position:50%;
	transform:rotate(180deg) rotateY(0);
}
.border{
	position:absolute;
	margin-left:2px; 
	margin-top:1px;
	border-radius:100%;
	box-shadow:0 0 0 2px rgba(0,0,0,0.5);
  transform:rotateY(0);
}

// looping through each one of them
@for $i from 1 through $raindrops{

  // generates a random number from 0 to 1, for the positioning
  $x:random();
  $y:random();

  // Random raindrop size and stretching.
  // Since each raindrop has different sizes, we'll do our sizing calculations here instead of on the main .raindrop selector
 	$drop-width:5px+random(11);
 	$drop-stretch:0.7+(random()*0.5);
	$drop-height:$drop-width*$drop-stretch;
	.raindrop:nth-child(#{$i}){
		// multiply the random position value by the container's size
		left:$x * $width;
		top:$y * $height;
    
		width:$drop-width;
		height:$drop-height;
    background-position:percentage($x) percentage($y);
	}

	.border:nth-child(#{$i}){
		// we'll do the same positioning for the drop's border
		left:$x * $width;
		top:$y * $height;

		width:$drop-width - 4;
		height:$drop-height;
	}
}



            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console