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 class="info">
    <i class="fas fa-info-circle"></i>
    <p>This mixin (your elements) need a "data-slice" attribute in the HTML tag, if you can't set this yourself, do it via JS.</p>
</div>

<section class="slice">
    <div class="slice__container">
        <span class="sliceText" data-slice="Katana">Katana</span>
        <div class="katana">
            <span></span><span></span>
        </div>
    </div>
    <div class="withJS">
        <span class="cut">Using JS</span>
        <span class="cut">Using JS</span>
        <span class="cut">Using JS</span>
    </div>
</section>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Staatliches&display=swap");
$bg: #cddad5;
$font: #4f4e55;
body {
    font-size: 16px;
    color: $font;
    background-color: $bg;
    height: 100vh;

    .info {
        display: flex;
        flex-direction: row-reverse;
        position: fixed;
        top: 0;
        right: 0;
        padding: 1rem;
        line-height: 1.25;

        i {
            font-size: 2rem;
            margin-left: 2rem;
            cursor: pointer;
        }

        p {
            opacity: 0;
            transform: translateX(150%);
            transition: 0.3s;
            margin: 0;
        }

        &.showInfo p {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

// CUT TEXT //
@mixin sliceText(
    $hoverColor: currentColor,
    $time: 0.1s,
    $horizontal: 0.06em,
    $vertical: 0.03em
) {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    text-decoration: none;
    transition: color 0.1s $time linear;
    line-height: 0;
    z-index: 1;

    &::before,
    &::after {
        content: attr(data-slice);
        display: inline-flex;
        color: transparent;
        text-align: center;
        width: 100%;
        height: 0.5em;
        transform: translate(0, 0);
        transition: transform $time linear, color 0.1s $time linear;
        user-select: none;
        overflow: hidden;
        font-size: 1em;
        z-index: -1;
    }

    &::before {
        align-items: flex-end;
    }
    &::after {
        align-items: flex-start;
    }

    &:active {
        transition: none;
        color: transparent;
        user-select: none;

        &::before,
        &::after {
            color: $hoverColor;
            transition: transform $time linear;
        }
        &::before {
            transform: translate(-#{$horizontal}, -#{$vertical});
        }
        &::after {
            transform: translate($horizontal, $vertical);
        }
    }

    @media (hover: hover) {
        &:hover,
        &:focus,
        &:focus-within,
        &:focus-visible {
            transition: none;
            color: transparent;

            &::before,
            &::after {
                color: $hoverColor;
                transition: transform $time linear;
            }
            &::before {
                transform: translate(-#{$horizontal}, -#{$vertical});
            }
            &::after {
                transform: translate($horizontal, $vertical);
            }
        }
    }

    @content;
}

// cuttext
.slice {
    display: grid;
    grid-template-rows: 1fr auto;
    place-items: center;
    height: 100vh;
    font-family: "Staatliches", sans-serif;
    letter-spacing: 2px;

    span {
        color: $font;
    }

    &__container .sliceText {
        color: #ed4c67;
        font-size: 5rem;
        letter-spacing: 10px;
        @include sliceText($font);

        // using drop-shadow instead of text-shadow
        filter: drop-shadow(0 1px 1px white);

        @media (min-width: 769px) {
            font-size: 10rem;
        }
    }

    > div:not(.slice__container) {
        display: flex;
        flex-wrap: wrap;

        > span {
            font-size: 18px;
            padding: 2rem;
            @include sliceText(#ed4c67, 0.2s, 2px, 1px);
        }
    }
}

.katana {
    position: relative;
    width: 170%;
    height: 36px;
    margin-left: -35%;
    margin-top: 8%;
    transform: rotate(0);
    transition: transform 0.3s ease;

    &.active {
        transform: rotate(3deg);

        &::after {
            transform: rotate(-3deg);
        }
    }

    &::after {
        content: "";
        position: absolute;
        width: 50%;
        height: 20px;
        bottom: -300%;
        left: 0;
        right: 0;
        margin: 0 auto;
        border-radius: 50%;
        background: rgba($font, 0.25);
        filter: blur(6px);
        transition: transform 0.3s ease;
    }

    span {
        position: absolute;
        height: 100%;
        background: $font;

        &::before {
            content: "";
            position: absolute;
            background: $font;
        }

        &:first-child {
            left: 0;
            width: 75%;
            border-radius: 0 0 0 40px;
            overflow: hidden;
            z-index: -1;

            &::before {
                top: 50%;
                left: 4%;
                height: 50%;
                width: 87%;
                background: linear-gradient(
                    180deg,
                    lighten($font, 15),
                    transparent 80%
                );
                border-radius: 0 6px 0 25px;
                border: 4px solid $bg;
                border-bottom: none;
            }
        }

        &:last-child {
            right: 0;
            width: 27%;
            border-radius: 4px 12px 12px 4px;
            border-left: 2px solid $bg;
            background: linear-gradient(
                70deg,
                $font 15%,
                $bg 16%,
                $font 17%,
                $font 28%,
                $bg 29%,
                $font 30%,
                $font 41%,
                $bg 42%,
                $font 43%,
                $font 54%,
                $bg 55%,
                $font 56%,
                $font 67%,
                $bg 68%,
                $font 69%,
                $font 80%,
                $bg 81%,
                $font 82%,
                $font
            );

            &::before {
                left: -14px;
                height: 200%;
                width: 22px;
                top: -50%;
                border-radius: 50%;
                border-left: 2px solid $bg;
                z-index: -1;
            }
        }
    }
}

              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", function (event) {
    // Adding the data attribute to elements
    document.querySelectorAll(".cut").forEach((link) => {
        link.setAttribute("data-slice", link.innerText);
    });

    document
        .querySelector('[data-slice="Katana"]')
        .addEventListener("mouseenter", katana);
    document
        .querySelector('[data-slice="Katana"]')
        .addEventListener("mouseleave", katana);

    function katana() {
        document.querySelector(".katana").classList.toggle("active");
    }

    document.querySelector(".info > i").addEventListener("click", function () {
        this.parentNode.classList.toggle("showInfo");
    });
});

              
            
!
999px

Console