Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                <div id="container">
  <h3>Choose your vertical alignment</h3>
  <div id="buttons">
    <button id="baseline" class="active">Baseline</button>
    <button id="top">Top</button>
    <button id="middle">Middle</button>
    <button id="bottom">Bottom</button>
    <button id="thirty">30%</button>
  </div>
  <div id="text" classname="baseline">

    <p>The studio was filled with the <span class="highlight">rich odour of roses</span>, and when the light summer wind stirred amidst the trees of the garden, there came through the open door the <span class="highlight">heavy scent of the lilac</span>,
      or the more delicate perfume of the <span class="highlight">pink-flowering thorn</span>.</p>

    <p>From the corner of the divan of Persian saddle-bags on which he was lying, smoking, as was his custom, innumerable cigarettes, Lord Henry Wotton could just catch the gleam of the honey-sweet and <span class="highlight">honey-coloured blossoms of a laburnum</span>,
      whose tremulous branches seemed hardly able to bear the burden of a beauty so flamelike as theirs; and now and then the fantastic shadows of birds in flight flitted across the long tussore-silk curtains that were stretched in front of the huge window,
      producing a kind of momentary Japanese effect, and making him think of those pallid, jade-faced painters of Tokyo who, through the medium of an art that is necessarily immobile, seek to convey the sense of swiftness and motion. The sullen murmur
      of the bees shouldering their way through the <span class="highlight">long unmown grass</span>, or circling with monotonous insistence round the dusty gilt horns of the <span class="highlight">straggling woodbine</span>, seemed to make the stillness
      more oppressive. The dim roar of London was like the bourdon note of a distant organ.</p>

    <p>In the centre of the room, clamped to an upright easel, stood the full-length portrait of a young man of extraordinary personal beauty, and in front of it, some little distance away, was sitting the artist himself, Basil Hallward, whose sudden disappearance
      some years ago caused, at the time, such public excitement and gave rise to so many strange conjectures.</p>

    <p>As the painter looked at the gracious and comely form he had so skilfully mirrored in his art, a smile of pleasure passed across his face, and seemed about to linger there. But he suddenly started up, and closing his eyes, placed his fingers upon
      the lids, as though he sought to imprison within his brain some curious dream from which he feared he might awake.</p>

    <p>"It is your best work, Basil, the best thing you have ever done," said Lord Henry languidly. "You must certainly send it next year to the Grosvenor. The Academy is too large and too vulgar. Whenever I have gone there, there have been either so many
      people that I have not been able to see the pictures, which was dreadful, or so many pictures that I have not been able to see the people, which was worse. The Grosvenor is really the only place."</p>

  </div>
  <p><em>The Picture of Dorian Gray</em>, by Oscar Wilde; via <a href="https://www.shmoop.com/picture-dorian-gray/chapter-1-full-text.html">via Schmoop</a></p>

</div>
              
            
!

CSS

              
                // https://flatuicolors.com/palette/in

body,
html {
  margin: 0;
  padding: 0;
  background-color: #2c3a47;
}

#buttons {
  display: grid;
  grid-gap: 0.2em;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  grid-auto-rows: max-content;

  & button {
    color: #f8efba;
    background-color: #2c3a47;
    border: 0;
    padding: 0.4em 1em;
    font-size: 1em;
    cursor: pointer;

    &.active {
      background-color: #f97f51;
    }

    &:focus {
      outline: 3px solid #d6a2e8;
    }

    &:hover {
      opacity: 0.9;
    }
  }
}

#container {
  transition: all 300ms ease-in-out;

  margin: 1em;
  padding: 1em;

  max-width: 600px;

  background-color: #f8efba;
  color: #2c3a47;

  & p {
    font-size: 1.2em;
    font-family: sans-serif;
    line-height: 1.5em;
    vertical-align: inherit;
    text-align: justify;

    & > span.highlight {
      display: inline-block;
      background-color: #eab543;
      padding-left: 0.2em;
      padding-right: 0.2em;
      overflow: hidden;
    }
  }
}

#text {
  // border: 1px solid red;
  &.baseline {
    p > span.highlight {
      vertical-align: baseline;
    }
  }
  &.top {
    p > span.highlight {
      vertical-align: top;
    }
  }
  &.middle {
    p > span.highlight {
      vertical-align: middle;
    }
  }
  &.bottom {
    p > span.highlight {
      vertical-align: bottom;
    }
  }
  &.thirty {
    p > span.highlight {
      vertical-align: 30%;
    }
  }
}

a {
  &:link {
    color: #1b9cfc;
  }
  &:visited {
    color: #82589f;
  }
  &:hover {
    color: #55e6c1;
  }
  &:active {
    color: #f97f51;
  }
}

              
            
!

JS

              
                const buttons = $('#buttons > button');
buttons.on('click', function() {
  buttons.removeClass('active');
  $(this).addClass('active');
  
  const id = $(this).attr('id');
  $('#text').removeClass();
  $('#text').addClass(id);
});
              
            
!
999px

Console