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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <center>Click on book</center>

<div class="book" id="test-book">
    <div class="pages-container">
        <div class="page">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi rem repellat fuga numquam laboriosam hic quis quia commodi ex recusandae ut architecto, quod nisi, delectus ea error officiis, id doloremque.</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae necessitatibus aut officia voluptates, ex repellendus reprehenderit! Minima repellat fugiat rem fugit incidunt placeat praesentium, saepe voluptates magni temporibus illo. Sequi?</p>
        </div>
        <div class="page duplex" id="test-duplex">
            <div class="page front">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam, esse.</p>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error aut reprehenderit maxime provident! Vel eveniet nisi ab molestias nesciunt quasi aperiam, omnis molestiae nemo exercitationem vitae id quis alias, assumenda tempore neque itaque tempora facilis placeat incidunt eaque at. Expedita maxime eum, debitis voluptatem. Deleniti!</p>
            </div>
            <div class="page back">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti distinctio maiores ratione animi vero, eius ipsa eum perferendis deleniti totam!</p>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed impedit numquam quibusdam nesciunt sint eius eaque laudantium officiis inventore veritatis!</p>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis est pariatur, ducimus voluptatem ut sint!</p>
            </div>
        </div>
        <div class="page">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore beatae deleniti asperiores, assumenda facere alias debitis amet nemo sequi quisquam, fugit placeat illo cum saepe unde dolorem fuga neque omnis.</p>
            <p>***</p>
        </div>
    </div>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Gentium+Book+Basic);

*,
*:before,
*:after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@keyframes leafLeft {
    0% {
        transform-origin: 0 0;
        transform: perspective(1000px) rotateY(0deg);
    }

    100% {
        transform-origin: 0 0;
        transform: perspective(1000px) rotateY(-180deg);
    }
}


@brown:       #60584A;
@light-brown: #D5D6BC;
@white:       #FFFFFF;


body {
    background: @light-brown;
    min-width: 38em;
}

center {
    margin: 1em auto;
    font: 400 1em / 1.2 'Gentium Book Basic';
}

p + p {
    margin-top: 1em;
}

.book {
    background: linear-gradient(to bottom, @brown, darken(@brown, 20%));
    height: 24em;
    width: 34em;
    margin: 1em auto;
    box-shadow: 0 1em 3em rgba(0, 0, 0, .3);
    padding: 1em;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    
    &:hover {
        cursor: pointer;
    }

    .pages-container {
        background: @light-brown;
        height: 100%;
        width: 100%;
        box-shadow: 0 0 .3em rgba(0, 0, 0, .3);
        position: relative;
        
        .page {
            position: absolute;
            height: inherit;
            width: 50%;
            padding: 1em;
            font: 400 1em / 1.2 'Gentium Book Basic';
            
            &:first-of-type,
            &.back{
                background: linear-gradient(to left, lighten(@brown, 20%), @light-brown 20%, @white 100%);
            }
            
            &:last-of-type,
            &.front {
                background: linear-gradient(to right, lighten(@brown, 20%), @light-brown 20%, @white 100%);
                margin-left: 50%;
            }
            
            &.duplex {
                animation-duration: 1s;
                animation-fill-mode: forwards;
                margin-left: 50%;
                z-index: 1;
                transform-style: preserve-3d;
                padding: 0;
                -webkit-font-smoothing: antialiased;
                
                &.leaf-left {
                    animation-direction: normal;
                    animation-name: leafLeft;
                    .back {   
                        background: linear-gradient(to left, lighten(@brown, 20%), @light-brown 20%, @white 100%);
                    }
                }
                
                &.leaf-right {
                    animation-direction: reverse;
                    animation-name: leafLeft;
                    
                    .back {
                        background: linear-gradient(to left, lighten(@brown, 20%), @light-brown 20%, @white 100%);
                    }
                }
                
                .front,
                .back {
                    backface-visibility: hidden;
                    width: 100%;
                    margin: 0;
                }

                .back {
                    transform: rotateY(180deg);
                }
            }
        }
    }
}
              
            
!

JS

              
                document.getElementById('test-book').addEventListener('click', (function() {
    var state = 1;
    
    return function() {
        var duplex = document.getElementById('test-duplex');

        switch (state) {
            case 1:
                duplex.classList.remove('leaf-right');
                duplex.classList.remove('leaf-left');
                duplex.offsetWidth = duplex.offsetWidth;
                duplex.classList.add('leaf-left');
                state = 2;
                break;
            case 2:
                duplex.classList.remove('leaf-left');
                duplex.classList.remove('leaf-right');
                duplex.offsetWidth = duplex.offsetWidth;
                duplex.classList.add('leaf-right');
                state = 1;
                break;
        }
    }
})());
              
            
!
999px

Console