Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="title" class="lesson-title label">
  <h1>
    <a href="">FINAL PROJECT</a>
  </h1>
  <p>This accordion was built to demonstrate the use of advanced CSS Selectors covered in the <a href="#">'Level up your CSS - Advanced Selectors'</a> class on Skillshare.</p>
</div>
<div class="accordion">
  <div class="draw" data-type="T01">
    <div class="label">Draw 1</div>
    <div class="desc">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
      <div class="desc-sub">
        <p>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
          viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
          quam ligula vel enim.
        </p>
      </div>
    </div>
  </div>
  <div class="draw" data-type="T02">
    <div class="label">Draw 2</div>
    <div class="desc">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
    </div>
  </div>
  <div class="draw" data-type="T03">
    <div class="label">Draw 3</div>
    <div class="desc">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
      <img class="image" src="assets/img/bike.png" alt="blue bike">
      <img class="image" src="assets/img/doughnuts.jpg" alt="doughnuts">
    </div>
  </div>
  <div class="draw" data-type="T02">
    <div class="label">Draw 4</div>
    <div class="desc">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
    </div>
  </div>
  <div class="draw" data-type="T01">
    <div class="label">Draw 5</div>
    <div class="desc">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
    </div>
  </div>
  <div class="draw" data-type="T03">
    <div class="label">Draw 6</div>
    <div class="desc">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque vestibulum augue, sed aliquam sem gravida a. Integer eu mi non massa porta ultrices. Nunc sed sodales odio. Vivamus id dapibus erat. Sed a nulla sed libero auctor aliquam. Nullam
        viverra blandit felis id tempus. Integer euismod facilisis quam eu fermentum. Quisque porttitor lacus id ipsum tempus molestie. Fusce blandit eleifend dolor. Quisque convallis, mi gravida luctus auctor, nibh diam rutrum neque, vel ullamcorper
        quam ligula vel enim.
      </p>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /*** GENERAL ***/

* {
    box-sizing: border-box;
    font-family: sans-serif;
}

body {
    margin: 0;
    padding: 0;
}

p {
    color: black;
}

a {
  color: inherit;
  text-decoration: none;
  font-weight: bold;
}

a:hover {
  color: #119DA4;
}

/*** HEADING ***/

/* #title {
    text-align: right;
} */

.lesson-title {
    text-align: center;
}

/* .lesson-title {
    text-align: left;
} */


/*** ACCORDION ***/

.accordion {
    max-width: 700px;
    margin: 40px auto;
}

.draw {
    cursor: pointer; /* to signify the user can click, required for iOS if element is NOT a button */
    border-bottom: 2px solid white;
}

.draw:last-of-type {
    border-bottom: 0;
}

.draw .label {
    background: #119DA4;
    color: #FFFFFF;
    padding: 20px;
}

.draw .desc {
    background: #F7FBFC;
    overflow: hidden;
    padding: 0 20px;
    max-height: 0px;
    transition: all 0.5s ease;
}

.draw .desc p ~ img {
    border: 10px solid black;
}

.draw img {
    width: 49%;
}

/* when user clicks on draw, this applies styles to the 'active' state*/
.draw.active .desc {
    max-height: 1000px;
    padding: 20px;
    transition: all 0.5s ease;
}

/*
    
    ATTRIBUTE SELECTORS

    Excerpt from W3C Schools: https://www.w3schools.com/cssref/css_selectors.asp

    [attribute]	        [target] Selects all elements with a target attribute
    [attribute=value]	[target=_blank]	Selects all elements with target="_blank"
    [attribute~=value]	[title~=flower]	Selects all elements with a title attribute containing the word "flower"
    [attribute|=value]	[lang|=en]	Selects all elements with a lang attribute value starting with "en"
    [attribute^=value]	a[href^="https"]	Selects every <a> element whose href attribute value begins with "https"
    [attribute$=value]	a[href$=".pdf"]	Selects every <a> element whose href attribute value ends with ".pdf"
    [attribute*=value]	a[href*="w3schools"]	Selects every <a> element whose href attribute value contains the substring “w3schools" */

.draw[data-type='T01'] .label {
    background: #E3B23C;
}

.draw img[alt~=bike] {
    transform: rotate(5deg);
}

.draw img[src$='.jpg'] {
    transform: scale(1.2);
}


/*
    Some examples of psuedo classes include: 
    ::before/::after,
    :hover,
    :focus,
    :visited,
    :not
*/

.draw .label:hover {
    background: #E3B23C;
}

.lesson-title h1::before {
    content: "// ";
    color: pink;
    font-size: 35px;
}

              
            
!

JS

              
                $('.draw').on('click', function() {
  $(this).toggleClass('active');
});
              
            
!
999px

Console