Jump to content

How can i add text with cursor

Go to solution Solved by tuanphan,

Recommended Posts

  • Replies 5
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Hi Tuanphan, i have applied the below mentioned code in the advance section this enable the text in the header section however it won't apply on rest of the specific page, is there any solution for this...Pls note that i need it to be mentioned in the landing page only, please check...

https://kiwianaimmigration.online/

<style>
    body {
        margin: 0;
    }

    .trail-container {
        position: absolute;
        top: 0;
        left: 0;
        pointer-events: none;
        z-index: 9999;
    }

    .trailing-word {
        position: absolute;
        font-size: 16px;
        color: #ffffff; /* Set your desired color */
        white-space: nowrap;
        opacity: 0.8;
    }
</style>

<script>
    document.addEventListener("DOMContentLoaded", function () {
        const container = document.createElement("div");
        container.className = "trail-container";
        document.body.appendChild(container);

        document.addEventListener("mousemove", function (e) {
            const word = document.createElement("div");
            word.className = "trailing-word";
            word.textContent = "Kiwiana Immigration wishes you a Happy New Year!";

            const x = e.clientX;
            const y = e.clientY;

            word.style.left = x + "px";
            word.style.top = y + "px";

            container.appendChild(word);

            // Remove the word after a certain period
            setTimeout(() => {
                container.removeChild(word);
            }, 50); // Set the time (in milliseconds) you want the word to stay
        });
    });
</script>

Edited by Navdeep
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.