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="module">
  <h2 class="stripe-5"><span>Background-Size</span></h2>
  <p>By carefully adjusting the ratio of the stripe width to the size of the background tile using trigonometric identities, you can create repeating, diagonal stripes with the <code>linear-gradient</code> function. </p>
  <h2 class="stripe-6"><span>With trig!</span></h2>
</div>

<figure>
  <figureCaption>
    <p>The length of the red line (repeat width of the stripes), and the angles are known.  The width and height of the black rectangle has to be calculated.</p>
    <p>Using the small triangle, we get <code>width = (stripeRepeatWidth) * sin(angle)</code>, using the large triangle we get <code>height = (stripeRepeatWidth) * cos(angle)</code>.</p>
  </figureCaption>
<svg viewBox="-25 -25 250 250" height="400px" width="400px">
  
  <line class="normal bold" x0="0" y2="100" transform="rotate(60)translate(57.73,-100)"/>
  <path class="angle" d="M5,8.6 A10,10,0 0 0 10,0"/>
  <path class="angle" d="M115.4,10 a10,10,0 0 1 -8.6,-5"/>
  <path class="angle" d="M0,-10h10v10" transform="rotate(60)translate(57.73,0)"/>
  
  <text x="10" dy="1em">α</text>
  <text x="100" y="10" dy="1em">α</text>
  
  <line class="bold" x0="0" x2="300" transform="rotate(60)"/>
  <line x0="0" x2="300" transform="rotate(60)translate(-50,100)"/>
  <line x0="0" x2="300" transform="rotate(60)translate(-25,50)"/>
  <line x0="0" x2="300" transform="rotate(60)translate(25,-50)"/>
  <line x0="0" x2="300" transform="rotate(60)translate(50,-100)"/>
  <line x0="0" x2="300" transform="rotate(60)translate(75,-150)"/>
  
  <rect class="outline" width="115.4" height="200px"/>
  
</svg>
</figure>
              
            
!

CSS

              
                .module {
  background: white;
  border: 1px solid #ccc;
  margin: 3%;
  > h2 {
    padding: 3rem;
    margin: 0 0 0.5rem 0;
  }
  > p {
    padding: 0 1rem;
  }
}

.stripe-5 {
  color: white;
  background: linear-gradient(
    45deg,
    #5d9634,
    #5d9634 50px,
    #538c2b 50px,
    #538c2b 100px,
    #5d9634 100px,
    #5d9634 150px,
    #538c2b 150px,
    #538c2b
  );
  background-size: 141.4px 141.4px; /* 100px * sqrt(2) */
} 

.stripe-6 {
  color: white;
  background: linear-gradient(
    60deg,
    #5d9634,
    #5d9634 50px,
    #538c2b 50px,
    #538c2b 100px,
    #5d9634 100px,
    #5d9634 150px,
    #538c2b 150px,
    #538c2b 200px,
    #5d9634 200px
  );
  background-size: 115.4px 200px; 
   /* sin(60) = 100px/width, i.e. width= 100px/sin(60)
      cos(60) = 100px/height, i.e. height = 100px/cos(60)
  */
} 

svg {
  display:block;
  border: solid 1px gray;
  margin: 1em auto;
}
svg rect.outline{
  fill:none;
  stroke:black;
}
svg line {
  stroke:green;
}
svg line.normal, svg path.angle {
  fill:none;
  stroke:red;
}
svg line.bold {
  stroke-width:2;
}
svg text {
  fill:red;
  font-family:serif;
}
code {
  display:inline-block;
  color:#041
}
              
            
!

JS

              
                
              
            
!
999px

Console