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>
            <div class="container">
                <div class="card">
                    <div class="closed img_wrapper">
                        <img src="https://images.unsplash.com/photo-1581003014628-16de2108de2c?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY1NzkwMjM0NA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" class="img"/>
                    </div>
                    <div class="closed text_wrapper">
                        <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat. Cras semper auctor neque vitae tempus. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae. Auctor elit sed vulputate mi sit amet mauris. Sit amet aliquam id diam maecenas ultricies mi. Scelerisque viverra mauris in aliquam sem fringilla ut morbi. Ultrices gravida dictum fusce ut placerat orci nulla pellentesque. Varius sit amet mattis vulputate enim nulla aliquet porttitor lacus. Ullamcorper velit sed ullamcorper morbi tincidunt ornare. Consectetur adipiscing elit pellentesque habitant morbi tristique.</p>
                    </div>
                </div>
                <div class="card">
                    <div class="closed img_wrapper">
                        <img src="https://images.unsplash.com/photo-1588155664232-8aa20befe9e7?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY1NzkwNDQwNA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" class="img"/>
                    </div>
                    <div class="closed text_wrapper">
                        <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat. Cras semper auctor neque vitae tempus. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae.&nbsp;</p>
                    </div>
                </div>
                <div class="card">
                    <div class="closed img_wrapper">
                        <img src="https://images.unsplash.com/photo-1596470778652-536211c85639?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY1NzkxODY5NA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" class="img"/>
                    </div>
                    <div class="closed text_wrapper">
                        <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat. Cras semper auctor neque vitae tempus. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae.&nbsp;</p>
                    </div>
                </div>
                <div class="card">
                    <div class="closed img_wrapper">
                        <img src="https://images.unsplash.com/photo-1570727624862-3008fe67a6be?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY1NzkxODYwMQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" class="img"/>
                    </div>
                    <div class="closed text_wrapper">
                        <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat. Cras semper auctor neque vitae tempus. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae.&nbsp;</p>
                    </div>
                </div>
                <div class="card">
                    <div class="closed img_wrapper">
                        <img src="https://images.unsplash.com/photo-1553600047-e8f97d6bf5a2?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY1NzkxODgxMA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" class="img"/>
                    </div>
                    <div class="closed text_wrapper">
                        <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat. Cras semper auctor neque vitae tempus. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae.Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae.&nbsp;</p>
                    </div>
                </div>
                <div class="card">
                    <div class="closed img_wrapper">
                        <img src="https://images.unsplash.com/photo-1582293041079-7814c2f12063?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxfDB8MXxyYW5kb218MHx8fHx8fHx8MTY1NzkxODk0Nw&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1080" class="img"/>
                    </div>
                    <div class="closed text_wrapper">
                        <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat. Cras semper auctor neque vitae tempus. Aliquam etiam erat velit scelerisque in. Iaculis nunc sed augue lacus viverra vitae congue eu consequat. Mi proin sed libero enim sed faucibus turpis. Mollis nunc sed id semper risus. Tempus iaculis urna id volutpat. Orci dapibus ultrices in iaculis nunc sed augue lacus viverra. Eu volutpat odio facilisis mauris sit amet massa vitae.&nbsp;</p>
                    </div>
                </div>
            </div>
        </section>
              
            
!

CSS

              
                html,
body {
    margin: 0;
    height: 100%;
    font-family: "Signika Negative", sans-serif, Arial;
}

body {
    overflow-x: hidden;
    overflow-y: scroll;
}

.container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    grid-column-gap: 20px;
    grid-row-gap: 20px;
    background-color: #1828e3;
    padding: 20px;
}

.card {
    width: 28vw;
    position: relative;
    display: flex;
    flex-direction: column;
    align-self: flex-start;
}

.img_wrapper {
    width: 100%;
    height: 200px;
}

.img_wrapper.closed {
    height: 28vw;
}

.img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.text_wrapper {
    background-color: #91cdf7;
    flex-grow: 1;
    overflow: hidden;
}

.text_wrapper.closed {
    height: 0;
}

.text {
    margin: 20px;
}





              
            
!

JS

              
                gsap.registerPlugin(Flip);

let cards = gsap.utils.toArray(".card");

cards.forEach((card) => {

    let imageWrapper = $(card).find(".img_wrapper"),
        textWrapper = $(card).find(".text_wrapper");

    $(card).click(() => {

      // I'd like to write one of each of these statements instead of one per child element
      
        const imageState = Flip.getState(imageWrapper);
        const textState = Flip.getState(textWrapper);

        $(imageWrapper).toggleClass("closed");
        $(textWrapper).toggleClass("closed");
        
        Flip.from(imageState, { duration: .5, ease: "power2.inOut" });
        Flip.from(textState, { duration: .5, ease: "power2.inOut" });

    });
});
              
            
!
999px

Console