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

              
                <body>
  <div class="container">
    <h1><span>Article</span></h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eu libero eu dui luctus hendrerit in ac tortor. Fusce semper, purus ac ornare efficitur, ex augue laoreet tortor, nec tristique nisi ex ac mi. Morbi luctus dictum leo, at sollicitudin orci faucibus vel. Praesent sit amet tincidunt sem. Suspendisse bibendum tellus et erat consequat, at facilisis lectus sollicitudin. Pellentesque a varius mi. Vestibulum finibus, lacus a laoreet vestibulum, ipsum nibh bibendum ligula, et auctor dui velit sed dolor. Vivamus id dapibus sem, a pulvinar enim. Maecenas pulvinar malesuada lectus, et porttitor enim cursus eget. Sed sodales aliquet mauris sit amet sodales. Mauris placerat eleifend lorem, id consequat ante ultricies sed. Pellentesque at leo convallis, facilisis lectus quis, ornare arcu. Nullam non libero eget nisi congue imperdiet sed ut turpis. Pellentesque quis nisi mattis, fringilla sem vitae, sodales justo. Nunc a nibh ipsum.</p>
    <h2>
      <span>Subtitle</span>
    </h2>
    <p>Aliquam a venenatis lacus, at volutpat massa. Aenean consequat mi eget neque ornare, ac tempor metus consectetur. Integer aliquam sodales lectus, sed dignissim diam venenatis ac. Duis gravida purus non tellus molestie, quis vehicula risus pulvinar. Donec urna arcu, cursus in nisi sed, dapibus aliquam lorem. Donec congue iaculis felis mollis dapibus. Maecenas sed nunc sed enim pretium fringilla quis sed turpis. Suspendisse id rutrum justo. Morbi a turpis turpis. Phasellus nec eros iaculis, aliquam lorem id, posuere libero. Phasellus tellus eros, interdum ac ultricies faucibus, tempor sed ex. Phasellus ac commodo lacus.
    </p>
  </div>
</body>
              
            
!

CSS

              
                body {
  background-color: #0F0923;
  color: #fefefe;
  display:flex;
  align-items: center;
  flex-direction: column;
  font-size:16px;
  font-family: 'titleFont';
}

h1 {
  font-size: 6.3em;
  margin: 0.2em 0;
  line-height: 1em;
  font-weight: normal;
}

h2 {
  font-size: 4.2em;
  margin: 0.2em 0;
  font-weight: normal;
  font-family: 'subFont';
}

p {
  font-size: 16px;
  font-weight: normal;
  font-family: 'textFont';
  text-align: justify;
  hyphens: auto;
}

.container {
  width: 90%;
}
              
            
!

JS

              
                const ptypoFactory = new Ptypo.default();
let containerDiv;
let startWidth;
let baseTitleWidth;
let baseSubWidth;

window.addEventListener('load', function() {
  containerDiv = document.querySelector('.container');
  startWidth = containerDiv.clientWidth;
  baseTitleWidth = 283;
  baseSubWidth = 200;
});

ptypoFactory.createFont(
  'titleFont',
  Ptypo.templateNames.GROTESK).then(function(font) {
    font.changeParams({
      'xHeight': 602,
      'thickness': 160,
      'capDelta': 280,
      'ascender': 310,
      'aperture': 1.2,
      'spacing': 0.8,
      'width': (startWidth - baseTitleWidth) / 98.92
    });

    window.addEventListener('resize', _.throttle(function(e) {
      var containerWidth = containerDiv.clientWidth;
      var width = Math.max(0, (containerWidth - baseTitleWidth) / 98.92)

      font.changeParam('width', width);
    }, 300));
});

ptypoFactory.createFont(
  'subFont',
  Ptypo.templateNames.GROTESK).then(function(font) {
    font.changeParams({
      'xHeight': 680,
      'thickness': 110,
      'capDelta': 280,
      'ascender': 310,
      'aperture': 1.2,
      'spacing': 0.8,
      'width': (startWidth - baseSubWidth) / 78.45
    });

    window.addEventListener('resize', _.throttle(function(e) {
      var containerWidth = containerDiv.clientWidth;
      var width = Math.max(0, (containerWidth - baseSubWidth) / 78.45);

      font.changeParam('width', width);
    }, 300));
});

ptypoFactory.createFont('textFont', Ptypo.templateNames.ELZEVIR).then(function(font) {
  font.changeParam('thickness', 60);
});
              
            
!
999px

Console