cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <div class="wrap">
  <p>The tags below have no additional layout properties assigned to them, apart from those defined by the UA stylesheet.</p>
  
  <p>Toggle highlighting on the <code>p</code> and <code>div</code> tags with the buttons to see how their vertical layouts differ.</p>
  <br />
  
  <span class="row text-center">
    <span class="column small-6">
      <button class="button secondary js-p-toggler">toggle p highlights</button>
    </span> 

    <span class="column small-6">
      <button class="button secondary js-div-toggler">toggle div highlights</button>
    </span> 
  </span>

  <br />

  <p class="reveal-p js-p">These lines of text are inside <code>p</code> tags.</p>
  <p class="reveal-p js-p">They automatically push content away vertically, without requiring any additional styling, and occupy 100% of their containers.</p>

  <div class="reveal-div js-div">These lines of text are inside <code>div</code> tags.</div>
  <div class="reveal-div js-div">You can use divs to create full width content,</div>
  <div class="reveal-div js-div">on their own lines,</div>
  <div class="reveal-div js-div">without introducing vertical space.</div>

</div>
            
          
!
            
              .wrap {
  margin-left: auto;
  margin-right: auto;
  max-width: 780px;
}

%reveal {
  transition: all .25s ease-in-out;
  outline: 1px solid transparent;
}

.reveal-p {
  @extend %reveal;
  
  &.is-active {
    background-color: transparentize(skyblue, .8);
    outline-color: transparentize(skyblue, .5);  
  }
}

.reveal-div {
  @extend %reveal;
  
  &.is-active {
    background-color: transparentize(hotpink, .8);
    outline-color: transparentize(hotpink, .5);  
  }
}
            
          
!
            
              const divs = document.querySelectorAll('.js-div');
const ps = document.querySelectorAll('.js-p');
const divToggler = document.querySelector('.js-div-toggler');
const pToggler = document.querySelector('.js-p-toggler');

function toggler({ elements, toggleElem }) {
  const elems = elements;
  const toggler = toggleElem;
  const activeClass = 'is-active';
  let isActive = false;

  function init() {
    toggler.addEventListener('mouseup', handleClick);
  }
  
  function handleClick() {
    const toggleFn = isActive ? 'remove' : 'add';
    
    [].slice.call(elems).map((el) => { 
      el.classList[toggleFn](activeClass);
    });
    
    isActive = !isActive;
  }
  
  init();
}

toggler({
  elements: divs,
  toggleElem: divToggler,
});

toggler({
  elements: ps,
  toggleElem: pToggler,
});
            
          
!
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