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="page-header__section">
        <div class="page-header__wrap">
            <div class="page-header__body">
                <h1 class="page-header__title">
                    Заголовок страницы с эффектом 3D вращения
                </h1>
                <div class="page-header__desc">
                    Далеко-далеко за словесными горами в стране гласных и согласных живут рыбные тексты. Продолжил диких
                    себя проектах приставка семантика, сих живет толку маленькая!
                </div>
            </div>
        </div>
    </div>

              
            
!

CSS

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

        :root {
            --index: calc(1vw + 1vh);
            --max_angle_x: .7deg;
            --max_angle_y: .5deg;
            --trans_option: transform 2.75s cubic-bezier(.075, .5, 0, 1), text-shadow 2.75s cubic-bezier(.075, .5, 0, 1);
            --perspective: 40px;
            --heightZ: 3.5px;

        }

        body {
            background-color: rgb(211, 211, 211);
            color: rgb(53, 53, 53);
            font-family: Arial, Helvetica, sans-serif;
            font-size: calc(var(--index) * 0.8);
        }

        h1 {
            font-size: 2.5em;
            margin-bottom: 15px;
        }

        .page-header__section {
            background-color: rgb(53, 53, 53);
            padding: 150px 0;
            perspective: var(--perspective)
        }

        .page-header__wrap {
            width: 45%;
            margin: 0 auto;
            padding: 30px;
            background-color: rgba(255, 255, 255, 0.3);
            border: double 5px #fff;
            color: #fff;
            text-align: center;
            transform: rotateX(0) rotateY(0);
            transition: var(--trans_option);
            transform-style: preserve-3d;
            will-change: transform;
        }

        .page-header__section:hover .page-header__wrap {
            transform: rotateX(calc(var(--mouseY) * var(--max_angle_x))) rotateY(calc(var(--mouseX) * var(--max_angle_y)));
            transition: var(--trans_option);
        }

        .page-header__section .page-header__wrap .page-header__body {
            transition: var(--trans_option);
        }

        .page-header__section:hover .page-header__wrap .page-header__body {
            transform: translateZ(var(--heightZ));
            transition: var(--trans_option);
            text-shadow: calc(var(--heightZ)) calc(var(--heightZ)) calc(var(--heightZ) * 2) rgba(0, 0, 0, .3);
        }

              
            
!

JS

              
                        jQuery(document).ready(function () {
            //Опредеяем блок, внутри которого будем отслеживать движение мыши
            effectWrap = jQuery(".page-header__section");
        });


        //Создаем слушатель, который вызывает функцию move() каждый раз, когда пользователь двигает курсор
        document.addEventListener("mousemove", function (e) {
            move(e.clientX, e.clientY);
        });

        //Задаем функцию - обработчик движения мыши
        function move(x, y) {
            //Определяем координаты центра блока effectWrap
            let cX = effectWrap.offset().left + effectWrap.outerWidth() / 2,
                cY = effectWrap.offset().top + effectWrap.outerHeight() / 2;

            //Вычисляем величину коэффициента смещения курсора от центра блока (от -1 до 1)
            let pX = (x - cX) / cX,
                pY = (y - cY) / cY;

            //Присваиваем полученные значения CSS переменным, если их значение находится в диапазоне -1 до 1 (курсор над областью отслеживания) и сбрасываем их в 0, если значение входит за рамки этого диапазона (курсор вне области отслеживания) 
            if ((pX >= -1 && pX <= 1) && (pY >= -1 && pY <= 1)) {
                document.body.style.setProperty('--mouseX', pX);
                document.body.style.setProperty('--mouseY', pY);
            } else {
                document.body.style.setProperty('--mouseX', 0);
                document.body.style.setProperty('--mouseY', 0);
            }
        }

              
            
!
999px

Console