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

              
                <section class="articles-container">
  <article class="article">
    <h2>Article header</h2>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo mollitia quae esse facere sed autem possimus et at, quibusdam consectetur error doloremque incidunt obcaecati, perspiciatis enim cum maiores ipsum? Blanditiis!</p>
    <p class="extra-content" data-is-toggled="false">Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni animi tenetur in! Quaerat nemo est iusto aperiam reprehenderit eum vero quo accusamus? Sed, blanditiis nisi repellat rem enim soluta dolorem!</p>
    <button class="read-more btn">Show More</button>
  </article>
  <article class="article">
    <h2>Article header</h2>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo mollitia quae esse facere sed autem possimus et at, quibusdam consectetur error doloremque incidunt obcaecati, perspiciatis enim cum maiores ipsum? Blanditiis!</p>
    <p class="extra-content" data-is-toggled="false">Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni animi tenetur in! Quaerat nemo est iusto aperiam reprehenderit eum vero quo accusamus? Sed, blanditiis nisi repellat rem enim soluta dolorem!</p>
    <button class="read-more btn">Show More</button>
  </article>
  <article class="article">
    <h2>Article header</h2>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo mollitia quae esse facere sed autem possimus et at, quibusdam consectetur error doloremque incidunt obcaecati, perspiciatis enim cum maiores ipsum? Blanditiis!</p>
    <p class="extra-content" data-is-toggled="false">Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni animi tenetur in! Quaerat nemo est iusto aperiam reprehenderit eum vero quo accusamus? Sed, blanditiis nisi repellat rem enim soluta dolorem!</p>
    <button class="read-more btn">Show More</button>
  </article>
</section>
              
            
!

CSS

              
                html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  font-family: "Lora", serif;
  margin: 0;
  height: 100vh;
  background: #eee;
  background: linear-gradient(to right, #3e5151, #decba4);
  overflow-x: hidden;
}

h2 {
  font-family: "Roboto Slab", serif;
  font-size: 28px;
  margin: 10px 0;
}

p {
  margin-bottom: 10px;
}

.articles-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  grid-gap: 20px;
  width: 100%;
  max-width: 1600px;
  height: 100%;
  align-items: center;
  justify-items: center;
  margin: 0 auto;
}

article {
  display: flex;
  flex-direction: column;
  max-width: 450px;
  padding: 20px;
  border-radius: 4px;
  background: rgba(96, 125, 139, 0.4);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.read-more {
  display: none;
  max-width: 120px;
  margin-top: 10px;
}

.btn {
  font-family: "Roboto Slab", serif;
  padding: 6px 0;
  border-radius: 0.12em;
  border: none;
  outline: none;
  color: #607d8b;
  background-color: #272727;
  cursor: pointer;
}

.extra-content {
  display: initial;
}

.show {
  display: initial !important;
}

@media (max-width: 920px) {
  
  .read-more {
    display: initial;
  }

  .extra-content {
    display: none;
  }

  body {
    background: linear-gradient(to right, #659999, #f4791f);
  }
  
}

              
            
!

JS

              
                const articles = document.querySelector(".articles-container");

const handleContentExpand = ({target}) => {
  if (target.className !== "read-more btn") return;
  const previousSibling = target.previousElementSibling;
  const isToggled = previousSibling.dataset.isToggled;

  previousSibling.classList.toggle("show");
  
  if (isToggled === "false") {
    target.textContent = "Show Less";
    previousSibling.dataset.isToggled = "true";
  } else {
    target.textContent = "Show More";
    previousSibling.dataset.isToggled = "false";
  }
};

articles.addEventListener("click", handleContentExpand);

              
            
!
999px

Console