cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv
Planned migrations in progress! PRO features temporarily disabled.

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <p class="balance-text">At the end of the third act, <span class="spoiler">he had to leave because <span class="spoiler">he was made of bacon.</span></span></p>

            
          
!
            
              html, body
  height: 100%

body, p
  margin: 0
  
body
  font: 20px 'PT Serif', serif
  text-align: center
  color: #333

p
  position: absolute
  top: 50%
  left: 10%
  transform: translateY(-50%)
  line-height: 1.7em
  width: 80%
    
.spoiler
  color: rgba(51, 51, 51, 1)
  text-shadow: 0 0 20px white
  transition: color 0.4s, text-shadow 0.4s, border-bottom-color 0.4s

\:not(:checked) + .spoiler
  &, .spoiler
    color: rgba(51, 51, 51, 0)
    text-shadow: 0 0 20px #333
    pointer-events: none
    
  label
    border-bottom-color: rgba(136, 136, 136, 0)

label
  position: relative
  top: -1px
  line-height: 2em
  margin: 0 1.5em 0 0.5em
  border-bottom: 1px solid #888
  vertical-align: middle
  font: bold 0.5em 'PT Sans', sans-serif
  text-transform: uppercase
  letter-spacing: 1px
  cursor: pointer
  transition: border-bottom-color 0.4s
    
input
  display: none

            
          
!
            
              // https://github.com/adobe-webplatform/balance-text
!function(a,b){"use strict";var c=function(a,b,c){var d;return function(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize"),function(a){"use strict";function d(){this.reset()}function k(){a(".balance-text").balanceText()}var b=document.documentElement.style,c=b.textWrap||b.WebkitTextWrap||b.MozTextWrap||b.MsTextWrap||b.OTextWrap;d.prototype.reset=function(){this.index=0,this.width=0};var e=function(a,b){for(var e,c=/\s(?![^<]*>)/g,d=[];null!==(e=c.exec(a));)d.push(e.index);return-1!==d.indexOf(b)},f=function(b){b.find('br[data-owner="balance-text"]').replaceWith(" ");var c=b.find('span[data-owner="balance-text"]');if(c.length>0){var d="";c.each(function(){d+=a(this).text(),a(this).remove()}),b.html(d)}},g=function(a){return b=a.get(0).currentStyle||window.getComputedStyle(a.get(0),null),"justify"===b.textAlign},h=function(b,c,d){c=a.trim(c);var e=c.split(" ").length;if(c+=" ",2>e)return c;var f=a("<span></span>").html(c);b.append(f);var g=f.width();f.remove();var h=Math.floor((d-g)/(e-1));return f.css("word-spacing",h+"px").attr("data-owner","balance-text"),a("<div></div>").append(f).html()},i=function(a,b){return 0===b||b===a.length||e(a,b-1)&&!e(a,b)},j=function(a,b,c,d,e,f,g){for(var h;;){for(;!i(b,f);)f+=e;if(a.html(b.substr(0,f)),h=a.width(),0>e?d>=h||0>=h||0===f:h>=d||h>=c||f===b.length)break;f+=e}g.index=f,g.width=h};a.fn.balanceText=function(){return c?this:this.each(function(){var b=a(this),c=5e3;f(b);var e="";b.attr("style")&&b.attr("style").indexOf("line-height")>=0&&(e=b.css("line-height")),b.css("line-height","normal");var i=b.width(),k=b.height(),l=b.css("white-space"),m=b.css("float"),n=b.css("display"),o=b.css("position");b.css({"white-space":"nowrap","float":"none",display:"inline",position:"static"});var p=b.width(),q=b.height(),r="pre-wrap"===l?0:q/4;if(i>0&&p>i&&c>p){for(var s=b.html(),t="",u="",v=g(b),w=Math.round(k/q),x=w;x>1;){var y=Math.round((p+r)/x-r),z=Math.round((s.length+1)/x)-1,A=new d;j(b,s,i,y,-1,z,A);var B=new d;z=A.index,j(b,s,i,y,1,z,B),A.reset(),z=B.index,j(b,s,i,y,-1,z,A);var C;C=0===A.index?B.index:i<B.width||A.index===B.index?A.index:Math.abs(y-A.width)<Math.abs(B.width-y)?A.index:B.index,u=s.substr(0,C),v?t+=h(b,u,i):(t+=u.replace(/\s$/,""),t+='<br data-owner="balance-text" />'),s=s.substr(C),x--,b.html(s),p=b.width()}v?b.html(t+h(b,s,i)):b.html(t+s)}b.css({position:o,display:n,"float":m,"white-space":l,"line-height":e})})},a(window).ready(k),a(window).smartresize(k)}(jQuery);

// populate with SPOILER labels
$('<label>spoiler</label>' +
  '<input type="checkbox">'
).insertBefore('.spoiler').each(function (i) {
  var isInput = i % 2;
  if (isInput) {
    $(this).attr('id', 'spoiler-' + Math.floor(i / 2));
  } else {
		$(this).attr('for', 'spoiler-' + i / 2);
  }
});

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console