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

              
                <section class="hero">
  <div class="hero__copy">
    <h1>Low Carbon Hero</h1>
    <p>Boost performance and reduce your site's impact with these two SVG tricks.</p>
  </div>
</section>

<section>
  <div class="inner-c">
    <h2>Why Focus on Carbon Footprints?</h2>
    <p>It's easy to overlook that something intangible like the internet consumes a lot of energy. In fact, <a href="https://internethealthreport.org/2018/the-internet-uses-more-electricity-than/" target="blank" rel="noopener">Mozilla's 2018 Internet Health Report</a> stated that: <em>The Internet’s data centers alone may already have the same CO2 footprint as global air travel.</em></p>
    
    <p>As technology improves and businesses seek to stand out, websites have become quite advanced. These sites may look good on the developer's computer or while using the office's fast internet, but the typical user may have a less pleasant experience.</p>
    
    <p>One of the heftiest contributors to a website’s weight — and carbon footprint — is the image. But did you know there’s a lightweight alternative that is also capable of driving emotion and engaging your users? This pen shows two examples of how to use SVGs to improve site speed, reduce environmental impact, and engage users.</p>
    
    <p>Enjoy!</p>
  </div>
</section>




<section class="embedded-svg">
  <!-- Get SVGs to behave like `object-fit: cover` with the attribute: `preserveAspectRatio`. Also, remove height and width attributes. -->
  <svg class="embedded-svg__bg" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" preserveAspectRatio="xMinYMin slice" viewBox="0 0 1200 675">
    <g mask="url(&quot;#SvgjsMask1259&quot;)" fill="none">
      <rect width="1200" height="675" x="0" y="0" fill="url(#SvgjsLinearGradient1260)"></rect>
      <path d="M0 0L594.09 0L0 54.43z" fill="rgba(255, 255, 255, .1)"></path>
      <path d="M0 54.43L594.09 0L865.08 0L0 80.7z" fill="rgba(255, 255, 255, .075)"></path>
      <path d="M0 80.7L865.08 0L1054.29 0L0 341.74z" fill="rgba(255, 255, 255, .05)"></path>
      <path d="M0 341.74L1054.29 0L1156.6399999999999 0L0 383.13z" fill="rgba(255, 255, 255, .025)"></path>
      <path d="M1200 675L1101.69 675L1200 635.95z" fill="rgba(0, 0, 0, .1)"></path>
      <path d="M1200 635.95L1101.69 675L782.6300000000001 675L1200 503.4100000000001z" fill="rgba(0, 0, 0, .075)"></path>
      <path d="M1200 503.41L782.63 675L497.52 675L1200 497.35z" fill="rgba(0, 0, 0, .05)"></path>
      <path d="M1200 497.35L497.52 675L328.53 675L1200 394.48z" fill="rgba(0, 0, 0, .025)"></path>
    </g>
    <defs>
      <mask id="SvgjsMask1259">
        <rect width="1200" height="675" fill="#ffffff"></rect>
      </mask>
      <linearGradient x1="10.94%" y1="-19.44%" x2="89.06%" y2="119.44%" gradientUnits="userSpaceOnUse" id="SvgjsLinearGradient1260">
        <stop stop-color="rgba(25, 149, 82, 1)" offset="0"></stop>
        <stop stop-color="rgba(108, 27, 195, 1)" offset="1"></stop>
      </linearGradient>
    </defs>
  </svg>

  <div class="embedded-svg__copy">
    <h2>Embedded SVG</h2>
    <p>Use the attribute <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio" target="_blank" rel-"noopener">preserveAspectRatio</a> to make the SVG behave like a background image's <code>object-fit: cover</code>.</p>
  </div>
</section>

              
            
!

CSS

              
                // media queries and vendor prefixes not included

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@900&family=Raleway:wght@400&display=swap');

section {
  font-family: Raleway, serif;
  font-size: 16px;
  line-height: 1.5rem;
}

h1, h2 {
  font-family: Montserrat, sans-serif;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.15em;
  line-height: 1.3em;
  text-transform: capitalize;
}


/*	Parallax hero
 * --------------------------
 */
.hero {
  @extend .zen; // vert/horz centered
  
  background: #1E1A38;
  background-attachment: fixed;
  background-image: url(https://mikebowen.me/wp-content/themes/cabbage-theme/assets/images/hero-bg.svg);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: cover;
  min-height: 90vh;
}

.hero__copy {
  @extend .inner-c;
  @extend .zen__child;
  
  color: white;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 2px rgb(30 26 56 / 50%);
  
  h1 {
    font-size: 36px;
  }
}



/*	Embedded SVG
 * --------------------------
 */
.embedded-svg {
  overflow: hidden;
  position: relative;
}

.embedded-svg__bg {
  bottom: 0;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  z-index: -1;
}

.embedded-svg__copy {
   @extend .inner-c;
  
  color: white;
  letter-spacing: 0.05em;
  text-align: center;
  text-shadow: 0 2px 2px rgb(30 26 56 / 50%);
  
  a {
    color: white;
    text-decoration: underline;
  }
}




/*	Misc utilities
 * --------------------------
 */
// typography and spacing
.inner-c {
  margin: 0 auto;
  max-width: 650px;
  padding: 6rem 1.5rem;
}

// Center vertically and horizontally
//
.totally-centered,
.zen {
	position: relative;
}

.zen__child {
  left: 0;
  margin: 0 auto;
  position: absolute;
  right: 0;
  text-align: center;
  top: 50%;
  transform: translateY(-50%);
}
              
            
!

JS

              
                
              
            
!
999px

Console