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

              
                <div class="container">
  <svg viewBox="0 0 1920 300">
    <polygon 
      id="red-triangle"
      fill="#f00"
      points="0 0 1920 81 1436 300">
    </polygon>
  </svg>
</div>
              
            
!

CSS

              
                body {
  background: #00f;
  margin:0;
  padding:0;
}

.container {
  border:1px solid red;
  width:100%;
  height:0;
  padding-top:15.625%; /* 300/1920 */
  position:relative;
}
svg {
  position:absolute;
  bottom:0;
  left:0;
  width:100%;
  height:100%;
  border:1px solid white;
}
#red-triangle {
  fill: #f00;
}

              
            
!

JS

              
                /*
Generate random svg points to animate to,
the idea (not working yet), is that it continuously 
animates to a new set of generated points

PROBLEM:
It generates the 1st set and never seems to use the
newly generated co-ords, it keeps repeating the initial
shape and 1st generated numbers
*/

var randNum = 0;
var pointsArray = [];

function createNumbers() {
  for (i=0; i<6; i++) {
  	if (i%2) {
    	//odd number, populate the "Y" part of the array
      //max value is 300, keeps it inside the viewbox
      pointsArray[i] = Math.floor(Math.random() * 300);
  	}
  	else {
      //this is equated first
      //even number, populate the "X" part of the array
      //max value is 1920, keeps it inside the viewbox
    	pointsArray[i] = Math.floor(Math.random() * 1920);
  	}
    // console.log(pointsArray[i]);
  }  
}
createNumbers();

var tl = new TimelineMax({repeat:-1, onRepeat:createNumbers});
tl.to("#red-triangle", 10, {attr: {points:pointsArray}})
              
            
!
999px

Console