Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container">
  <h1 class="title">Abc</h1>

  <input class="slider" type="range" min="0" max="20" value="0" autofocus/>
  <p>Use the ◀︎ or ▶︎ keys to tab through the OpenType variations in this <a href="https://color.typekit.com/">color font</a></p>
  
  <code class='code'><pre>h1 {
  font-family: "trajan-color";
  font-feature-settings: "<span class="feature">ss00</span>";
}</pre></code>
</div>

            
          
!
            
              html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

* {
  box-sizing: border-box;
}

h1 {
  font-family: "trajan-color";
  font-size: 200px;
  line-height: 1.3;
  margin: 0;
  padding: 0;
  font-weight: 400;
  margin-bottom: 0;
}

input {
  font-size: 20px;
  &:hover {
    cursor: pointer;
  } 
}

.container {
  overflow: hidden;
  width: 100%;
  height: 100%;
  background-color: #222222;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background-color .5s ease;
}

p {
  margin-bottom: 30px;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
font-family: -apple-system, Helvetica, sans-serif;
}

a {
  color: rgba(255,255,255,0.9);
  transition: .3s color ease;
  
  &:hover {
    color: rgba(255,255,255,1);
  }
}

.code {
  padding: 10px 30px;
  border-radius: 2px;
  right: 0;
  top: 0;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid rgba(0,0,0,.4);
  background-color: rgba(0,0,0,.1);
}

pre {
  font-family: "Lucida Console","Lucida Sans Typewriter",monaco,"Bitstream Vera Sans Mono",monospace;
}
            
          
!
            
              const slider = document.querySelector('.slider');
const title = document.querySelector('.title');
const container = document.querySelector('.container');
const colors = [
  '#222222', 
  '#777777', 
  '#b3857f',
  '#8fa9b5',
  '#873e35',
  '#dcd8ce',
  '#f0f0f0',
  '#404040',
  '#ddecec',
  '#2a6cd1',
  '#555',
  '#754428',
  '#a5d1cf',
  '#6c8e9e',
  '#fde3d8',
  '#888',
  '#222',
  '#afafaf',
  '#111',
  '#fab59a',
  '#ccc'
];

// title.setAttribute('style', 'font-feature-settings: "ss08"');

slider.addEventListener('input', function(e){
  let val = fixString(this.value);
  let fontFeature = `font-feature-settings: "${val}"`;
  let color = getColor(this.value);
  let backgroundColor = `background-color: ${color}`;
  title.setAttribute('style', fontFeature);
  container.setAttribute('style', backgroundColor);
  code(val);
});


function fixString(sliderValue){
  // if slider is less than ten add a '0' to the beginning
  if(sliderValue < 10) { 
    sliderValue = `0${sliderValue}`;
  }
  // prepend 'ss' to the string
  return `ss${sliderValue}`;
}

function getColor(num){
  return colors[num];
}

function code(variant) {
  const feature = document.querySelector('.feature');
  feature.innerText = variant;
}


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console