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

              
                <html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>
      Thick Lines: Peaks
    </title>
  </head>

  <body>
    <div class="peak-group-1">
      <div class="left-peak"></div>
      <div class="right-peak"></div>
    </div>
    <div class="peak-group-2">
      <div class="left-peak"></div>
      <div class="right-peak"></div>
    </div>
    <div class="peak-group-3">
      <div class="left-peak"></div>
      <div class="right-peak"></div>
    </div>
    <div class="peak-group-4">
      <div class="left-peak"></div>
      <div class="right-peak"></div>
    </div>
    <div class="peak-group-5">
      <div class="left-peak"></div>
      <div class="right-peak"></div>
    </div>
  </body>
</html>

              
            
!

CSS

              
                *,
*:after {
  margin: 0;
  padding: 0;
}

body {
  background-color: hsl(181, 49%, 56%);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

// Each group contains two peaks (in retrospect, I should have
// called this ‘%twin-peaks’)
%peak-group {
  position: absolute;
  width: 100%;
}

// We use these a bunch, so it’s best to stash them in vars
$peak-height: 24vh;
$peak-width: 78vw;

// Generate each peak using the good old-fashioned CSS triangle trick
%peak {
  border-color: transparent;
  border-style: solid;
  
  // The left and right borders add up to our desired width, so we divide
  // the desired width by two to get the correct ‘border-width’
  border-width: $peak-height ($peak-width / 2);
  height: 0;
  position: absolute;
  bottom: 100%;
  width: 0;
  
  // Use a pseudoelement to provide the ‘base’ of our peaks to avoid
  // the ‘floating mountain’ effect
  &:after {
    content: '';

    // Kind of arbitrary, really; this could have been any value that
    // prevented daylight between the peaks
    height: $peak-height;
    position: absolute;

    // Subtracting 1px fixes an occasional subpixel-rounding gremlin
    top: calc(#{$peak-height} - 1px);
    
    // Since the width of the parent element is zero, we need to bump this out
    // to the left by half the width of the peak so it lines up properly
    left: ($peak-width / 2) * -1;
    width: $peak-width;
  }
}

// Stash our colours in a list...
$peak-colors: (
  hsl(28, 100%, 24%),
  hsl(27, 91%, 31%),
  hsl(26, 81%, 39%),
  hsl(25, 77%, 47%),
  hsl(25, 91%, 54%)
);

// ...and loop over it to draw our peak groups
@each $color in $peak-colors {

  // It’s handy to stash this in a var
  $index: index($peak-colors, $color);

  // Using the index in the class name gives us ‘.peak-group-1’,
  // ‘.peak-group-2’, etc.
  .peak-group-#{$index} {
    @extend %peak-group;
    
    // The peak group overlap is 17vh. Sass lists are one-indexed; so to get
    // our first peaks to sit at the bottom of the stack, we subtract one
    // from the index to multiply the transform by zero.
    bottom: 17vh * ($index - 1);
    
    // We’re stacking as we go, so each additional leaf goes underneath
    // the previous one
    z-index: $index * -1;
    .left-peak,
    .right-peak {
      border-bottom-color: $color;
      &:after {
        background-color: $color;
      }
    }
  }
}

.left-peak,
.right-peak {
  @extend %peak;
}

// I could get fancy and use a list for this like I did for ‘Foliage’, but
// that level of complexity isn’t really necessary here

.left-peak {
  left: -13vw;
}

.right-peak {
  right: -13vw;
}

              
            
!

JS

              
                
              
            
!
999px

Console