css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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>@font-face code generator</h1>
<details>
  <summary>Instructions</summary>
   <p>The following code generator outputs a web font embed code, which allows you to declare <code>font-family</code> once, and to use <code>font-weight</code> and <code>font-style</code> to switch between different weights. </p>
  <pre><code>body {
  font-family: "Open Sans", sans-serif;
}
/* headings and other bold text will use 
   the bold weight of our custom font */</code></pre>
    <p>This is opposed to the default Font&nbsp;Squirell method of applying different <code>font-family</code>s to each actual weight, whilst the weight and the style of all weights is set to "normal".</p>
  <pre><code>body {
  font-family: "Open Sans Regular", sans-serif;
}
h1 {
  font-family: "Open Sans Bold", sans-serif;
  font-weight: normal; /* prevent faux-bold */
}</code></pre>
</details>
<form action="#" id="fontDetails">
  <fieldset>
    <legend>Global Settings</legend>
    <p>
      <label for="name">Font-family name:</label>
      <input type="text" name="name" id="name" value="Open Sans Hebrew" />
    </p>
    <p>
      <label for="url">Font folder (relative) url:</label>
      <input type="text" name="url" id="url" value="../fonts/" />
    </p>
  </fieldset>
  <p id="addHere" class="button-container">
    <button id="addweight" class="button addweight"><span class="plus">+</span> add weight</button>
    <input type="submit" class="button btn-blue submit" value="update code" />
  </p>
</form>  
<p>
  <label for="code">CSS embed code:</label>
  <textarea spellcheck='false' name="code" id="code" cols="30" rows="10"></textarea>
</p>
<script id="webfontTemplate" type="lavi/template">
  @font-face {
    font-family: '{{name}}';
    src: url('{{url}}{{file}}.eot');
    src: url('{{url}}{{file}}.eot?#iefix') format('embedded-opentype'),
         url('{{url}}{{file}}.woff') format('woff'),
         url('{{url}}{{file}}.ttf') format('truetype'),
         url('{{url}}{{file}}.svg#{{svgid}}') format('svg');
    font-weight: {{weight}};
    font-style: {{style}};
}
</script>
<script id="legendTemplate" type="lavi/template">
  <fieldset class="weight">
    <legend>Weight: <span>400, normal</span></legend>
      <p>For each weight there should be a different file name, a different svg id, and a different weight or style.</p>
    <p>
      <label for="file{{counter}}">Font files name:</label>
      <input type="text" name="file{{counter}}{{counter}}" id="file{{counter}}" value="opensanshebrew-normal-webfont" />
    </p>
    <p>
      <label for="svgid{{counter}}">Svg font id:</label>
      <input type="text" name="svgid{{counter}}" id="svgid{{counter}}" value="open_sans_hebrewnormal" />
    </p>
    <p>
      <label for="weight{{counter}}">Font weight:</label>
      <input type="text" name="weight{{counter}}" id="weight{{counter}}" value="400" class="input-weight" />
    </p>
    <p>
      <label for="style{{counter}}">Font style:</label>
      <input type="text" name="style{{counter}}" id="style{{counter}}" value="normal" class="input-style" />
    </p>
  </fieldset>
</script>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700|Raleway:200);
body {
  font-family: "Open Sans", sans-serif;
  line-height: 1.5; 
}
h1 {
  margin-bottom: 10px;
  font-family: "Raleway", sans-serif;
  font-weight: 200; 
  text-transform: uppercase;
  font-size: 2.3em; 
  line-height: 1; 
}
pre {
  box-shadow: inset 0 4px 3px -1px rgba(0,0,0,0.1), inset 0 1px 1px 1px rgba(0,0,0,0.3); 
  padding: 10px;
  border-radius: 3px;
}
.container {
  max-width: 600px;
  margin: auto;
}
.plus {
  display: inline-block;
  border: 1px solid;
  width: 20px;
  height: 20px;
  vertical-align: 0;
  line-height: 20px;
  font-size: 20px;
  border-radius: 50%;
  color: #88d7ff;
  margin-left: -7px;
  margin-right: 3px;
}
form {
  label {
    float: left;
    clear: left;
    width: 195px;
    height: 28px;
    line-height: 28px;
    
    padding-right: 5px;
  }
}
input[type=text], textarea {
  border-radius: 3px;
  color: #777;
  border: 1px solid;
  padding: 3px 5px;
  &:focus {
    color: #000;
    outline: none;
  }
}
input[type=text] {
  height: 20px;
  width: 300px;
}
fieldset {
  background: #ddd;
  margin: 10px 0;
  border: none;
}
legend {
  padding: 3px 10px;
  background: #777;
  color: #fff;
  text-transform: uppercase;
  font-size: 0.8em;
}
.button-container {
  overflow: hidden; 
  padding-bottom: 5px;
}
.addweight {
  float: left;
}
.submit {
  float: right;
}
.button {
  background: #666;
  color: #fff;
  border: 2px solid #666;
  padding: 8px 18px;
  border-radius: 3px;
  text-transform: capitalize; 
  box-shadow: 0 4px 3px -1px rgba(0,0,0,0.1), 0 1px 1px 1px rgba(0,0,0,0.3); 
  opacity: 0.8;
  &:hover, &:focus {
    opacity: 1;
  }
  &:focus {
    box-shadow: 
        0 4px 3px -1px rgba(0,0,0,0.1), 
        0 1px 1px 1px rgba(0,0,0,0.3),
        0 0 0 2px #fff inset;  
    outline: none;
  }
  &:active {
    padding: 10px 20px;
    border: none;
    opacity: 1;
      box-shadow: inset 0 4px 3px -1px rgba(0,0,0,0.1), inset 0 1px 1px 1px rgba(0,0,0,0.3); 
  }

}
.btn-blue {
  background: #08c;
  color: #fff;
  border: 2px solid #08c;
}
label[for="code"] {
  display: block;
}
textarea, code {
  font-family: consolas, monaco, monospace;
}
textarea {
  padding: 3px;
  width: 100%; 
  height: 300px;
  box-sizing: border-box;
  font-size: 0.8em;
}
summary {
  padding: 10px;
  cursor: pointer;
  &:hover {
    background: #DDD;
  }
}
            
          
!
            
              var content = [],
    template = $.trim( $('#webfontTemplate').html() ),
    templateLegend = $.trim( $('#legendTemplate').html() ),
    frag,
    counter=-1,
    code = $("#code");

function updateCode() {
  frag = '';
  for( i=0; i<=counter; i++ ) {
    frag += template.replace( /{{name}}/ig, $("#name").val() )
             .replace( /{{url}}/ig, $("#url").val() )
             .replace( /{{file}}/ig, $("#file"+i).val() )
             .replace( /{{svgid}}/ig, $("#svgid"+i).val() )
             .replace( /{{weight}}/ig, $("#weight"+i).val() )
             .replace( /{{style}}/ig, $("#style"+i).val() ) + "\n";
  }
  code.html(frag);
}

function changeLegend() {
    $(".input-weight, .input-style").on("blur", function(){
    var me = $(this),
        fieldset = me.parents("fieldset.weight"),
        weight = fieldset.find('.input-weight').val(),
        style = fieldset.find('.input-style').val(),
        text =  weight + ', ' + style;
    fieldset.find("legend span").text( text );
  });
}
function addWeight() {
  counter++;
  frag = templateLegend.replace( /{{counter}}/ig, counter );
  $( "#addHere" ).last().before(frag);
  changeLegend();
}

$("#fontDetails").on("submit", function(e){
  updateCode();
  e.preventDefault();
});

$("#addweight").on("click", function(e){
  addWeight();
  e.preventDefault();
});

addWeight();

/*! http://mths.be/details v0.1.0 by @mathias | includes http://mths.be/noselect v1.0.3 */
;(function(a,f){var e=f.fn,d,c=Object.prototype.toString.call(window.opera)=='[object Opera]',g=(function(l){var j=l.createElement('details'),i,h,k;if(!('open' in j)){return false}h=l.body||(function(){var m=l.documentElement;i=true;return m.insertBefore(l.createElement('body'),m.firstElementChild||m.firstChild)}());j.innerHTML='<summary>a</summary>b';j.style.display='block';h.appendChild(j);k=j.offsetHeight;j.open=true;k=k!=j.offsetHeight;h.removeChild(j);if(i){h.parentNode.removeChild(h)}return k}(a)),b=function(i,l,k,h){var j=i.prop('open'),m=j&&h||!j&&!h;if(m){i.removeClass('open').prop('open',false).triggerHandler('close.details');l.attr('aria-expanded',false);k.hide()}else{i.addClass('open').prop('open',true).triggerHandler('open.details');l.attr('aria-expanded',true);k.show()}};e.noSelect=function(){var h='none';return this.bind('selectstart dragstart mousedown',function(){return false}).css({MozUserSelect:h,msUserSelect:h,webkitUserSelect:h,userSelect:h})};if(g){d=e.details=function(){return this.each(function(){var i=f(this),h=f('summary',i).first();h.attr({role:'button','aria-expanded':i.prop('open')}).on('click',function(){var j=i.prop('open');h.attr('aria-expanded',!j);i.triggerHandler((j?'close':'open')+'.details')})})};d.support=g}else{d=e.details=function(){return this.each(function(){var h=f(this),j=f('summary',h).first(),i=h.children(':not(summary)'),k=h.contents(':not(summary)');if(!j.length){j=f('<summary>').text('Details').prependTo(h)}if(i.length!=k.length){k.filter(function(){return this.nodeType==3&&/[^ \t\n\f\r]/.test(this.data)}).wrap('<span>');i=h.children(':not(summary)')}h.prop('open',typeof h.attr('open')=='string');b(h,j,i);j.attr('role','button').noSelect().prop('tabIndex',0).on('click',function(){j.focus();b(h,j,i,true)}).keyup(function(l){if(32==l.keyCode||(13==l.keyCode&&!c)){l.preventDefault();j.click()}})})};d.support=g}}(document,jQuery));
$('details').details();

            
          
!
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.
Loading ..................

Console