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='intro'>
  <h3>Simple background full of animated stars</h3>
  <div class='customization-panel'>
    <div class='customization-title'>Customization</div>
    <div class='customization-js'>
      <div>In the js</div>
      <ul>
        <li>Number  of stars</li>
        <li>Min and max radius of the stars</li>
        <li>Rotation speed</li>
        <li>Area to be filled with stars</li>
      </ul>
    </div>
    <div class='customization-css'>
      <div>In the css</div>
      <ul>
        <li>Color of th star</li>
        <li>Orbit radius<li>
      </ul>
    </div>
  </div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Jura|Rajdhani');

body{background-color: #000;}
.star{display: block; background-color: #fff; position: absolute; border-radius: 100%; animation-timing-function: linear;animation-iteration-count: infinite;}

@keyframes move_right {
   from { transform: rotate(0deg) translateX(8px) rotate(0deg); }
    to   { transform: rotate(360deg) translateX(8px) rotate(-360deg); }
}

@keyframes move_left {
   from { transform: rotate(0deg) translateX(8px) rotate(0deg); }
    to   { transform: rotate(-360deg) translateX(8px) rotate(360deg); }
}

/* the intro panel */
.intro{color:#63baf7; margin: 1em; font-family: Jura; font-size: 11pt}
.intro h3{font-size: 16pt; margin-bottom: 0}
.intro ul {padding-left: .3em;}
.intro li {list-style-type: none; margin-left: .5em}
.intro .customization-panel{display: flex;flex-wrap: wrap;}
.intro .customization-title{flex-basis : 100%;padding: 10px 0; font-size: 14pt; text-shadow: 0 0 .3em #63baf7; color: #fff;}
.intro .customization-js{margin-right: 2em;}
              
            
!

JS

              
                var number_of_star = 150;

var random_number = function(min, max){
		return Math.floor(Math.random() * (max - min + 1)) + min;
};

var createStars = function(){
	var star_rotation = 'move_right;';
	for(var i=0; i<number_of_star; i++){
		rot= (star_rotation=='move_right;'?'move_left;':'move_right;');
		var star_top = random_number(0,document.documentElement.clientHeight);
		var star_left = random_number(0,document.documentElement.clientWidth);
		var star_radius = random_number(0,4);
		var  star_duration= random_number(6,16);

		document.body.innerHTML += "<div class='star' style='top: "+star_top+"px; left: "+star_left+"px; width: "+star_radius+"px; height: "+star_radius+"px; "+
		"animation-name:"+star_rotation+"; animation-duration: "+star_duration+"s;'></div>";
	}
};

createStars();

              
            
!
999px

Console