Jump to content

How to keep the animated text looping.

Recommended Posts

  • Replies 4
  • Views 214
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted
5 hours ago, vikikai said:

Is there a code to make the typing text animation looping?

What code are you using?

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

📈 SEO Space (Referral link)
Ⓜ️ 
Will Myers' Plugins & Tutorials (Referral link)
 🔌 Ghost Squarespace Plugins (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲SQSP Themes (Referral link) 
Spark Plugin (Referral link) 
 🖼️Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) 

 Did I help? Buy me a coffee?

Posted

add this code to code injection > footer :

<script>
  document.addEventListener("DOMContentLoaded", function () {
    const text = "Your Semi-Title Text Here";
    const element = document.querySelector("#semi-title");
    let index = 0;

    function typeWriter() {
      if (index < text.length) {
        element.innerHTML += text.charAt(index);
        index++;
        setTimeout(typeWriter, 100); // Adjust typing speed here
      } else {
        setTimeout(() => {
          element.innerHTML = ""; // Clear text
          index = 0;
          typeWriter(); // Restart typing
        }, 2000); // Pause before restarting
      }
    }

    typeWriter();
  });
</script>

here, text will be replaced by you what you want.

add this code to custom css:

#semi-title {
  font-size: 24px; /* Adjust size as needed */
  font-weight: bold;
  color: #333; /* Customize color */
  /* Add any additional styling here */
}

add this code to code block:

<span id="semi-title"></span>

 

Posted

For Code Block:

Quote

<div class="typeit">Type here</div> 

 

 

For Custom CSS

Quote

.typeit {
  overflow: hidden; 
  font-size:25px; /* this can be any font size you want */
  border-right: 2px solid #50bdb8; /* change this color in the keyframe too */
  white-space: nowrap; 
  margin: 0 auto; 
  animation: 
    typeit 3.5s steps(40) infinite,
    right-border .5s step-end infinite;
}
@keyframes typeit {
  from { width: 0 }
  to { width: 100% }
}
@keyframes right-border {
  from, to { border-color: transparent }

I only gave that a shot but it worked.

 

Posted

add this code to code injection > footer :

<script>
  document.addEventListener("DOMContentLoaded", function () {
    const text = "Your Semi-Title Text Here";
    const element = document.querySelector("#semi-title");
    let index = 0;

    function typeWriter() {
      if (index < text.length) {
        element.innerHTML += text.charAt(index);
        index++;
        setTimeout(typeWriter, 100); // Adjust typing speed here
      } else {
        setTimeout(() => {
          element.innerHTML = ""; // Clear text
          index = 0;
          typeWriter(); // Restart typing
        }, 2000); // Pause before restarting
      }
    }

    typeWriter();
  });
</script>

 

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.