octocatstartv

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
via CSS Lint

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
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <article>
    <h1>Heading 1</h1>

    <div class="buttons">
      <button>$75 Buy!</button>
      <button>PDF</button>
    </div>

    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget,
    tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  </article>

  <article>
    <h1>Heading 2</h1>

    <div class="buttons">
      <button>$75 Buy!</button><button>PDF</button>
    </div>

    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget,
    tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  </article>

  <article>
    <h1>Heading 3</h1>

    <div class="buttons">
      <button>$75 Buy!</button><button>PDF</button>
    </div>

    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget,
    tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  </article>

  <article>
    <h1>Heading 4</h1>

    <div class="buttons">
      <button>$75 Buy!</button><button>PDF</button>
    </div>

    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget,
    tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  </article>
            
          
!

CSS

            
              article {
  width: 100%;
  margin: 0 auto;
  opacity: 0.8;
}

h1 {
  text-align: center;
  color: #e05f5a;
  margin-bottom: 0;
  font-size: 50px;
  cursor: pointer;
}

.buttons {
  display: none;
  margin-top: 5px;
  text-align: center;
}

p {
  display: none;
  color: white;
  padding: 10px;
  width: 35%;
  margin: 0 auto;
}
            
          
!

JS

            
              $(function(){
  var h1 = $("h1"); //Get all the h1's
  var article = $("article"); //Get the article
  var all = $("article>.buttons, article>p"); //Get all the buttons and the p elements
  
  h1.on("click", function(){ //when the user clicks any h1
    all.slideUp(600); //slide up (or remove) all the buttons and p elements
    h1.css("color", "#e05f5a"); //change the color of the h1's to default
    article.css("background", "white"); //change the article color to default
    
    $(this).css("color", "white").siblings(".buttons, p").slideDown(600).parents("article").css("background", "#e05f5a"); //change the current h1 to a white color; show the siblings (buttons and p elements) by sliding down; change the background of the article
  });
});
            
          
!
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