w3tweaks.com
  • Effects
    • Scroll Effects
    • Text Effects
    • Shadow
  • Essentials
    • Arrows
    • Buttons
    • Background Patterns
    • Border Examples
    • Cards
    • Color Palettes
    • Dividers
    • Link styles
    • Loaders
    • Modal Windows
    • Notifications
    • Progress bar
    • Quote styles
    • Spinner
    • Tooltips
  • Media
    • Calendars
    • Carousels
    • Clocks
    • Gallery
    • Music Players
    • Sliders
    • Slideshows
    • Tables
    • Thumbnails
  • Navigation
  • Inputs
    • Range Sliders
    • Checkboxes
    • Toggle Switches
  • Script
    • Angularjs
    • Backbone.js
    • bootstrap
    • jQuery
    • ReactJs
    • JavaScript
    • Syntax Highlighters
    • tryit editor
    • PHP
  • API’s
    • Facebook
    • Google
    • Indeed
    • Twitter
    • YouTube
  • Tools
w3tweaks.com
Home CSS Code Demos

Show Animated sentence line by line using JS and CSS

September 20, 2019
in CSS Code Demos

Show Animated sentence line by line using JS and CSS. This text effect is developed using CSS, JavaScript and HTML. Demo and Download available.

You might also like

CSS Shapes Forest Collection Spring Summer 2020

CSS Button Concept for Remove and Success

Three Pure different CSS Button effects

Easy customizable simple CSS buttons

Rounded CSS buttons with mouseover effect

Collection of CSS3 animated buttons to spice up your site

Demo Download

Authorycw
CreatedSEPTEMBER 19, 2018
LicenseOpen
Compatible browsersChrome, Firefox, Safari

HTML Snippet

<base target="_blank"/> <h1>CSS JS 2018+ </h1> <h2>isolation</h2> <article>   <p class="tokenize">This paragraph is clipped by CSS <code>clip-path:polygon(..) </code>which is being updated with <a href="//css-tricks.com/updating-a-css-variable-with-javascript/">CSS Variables</a> controlled by JS.     You'll find that in the JS source, neither DOM nodes creation,      nor string manipulation; It only updates CSS Variables      of existing elements.<br/><br/>The styling *logic* is scoped in one place, the stylesheet.      Coders will not and should not know how it is implemented.(E.g. Tokenize fx is done by clip-path)      What they need to do is to populate CSS Variables. <a href="//developers.google.com/web/updates/2018/03/cssom">CSSTOM</a> will help a lot. <br/><br/>There are few limitations of CSS Variables<br/>1) Not every rule can be parametrized (keyframes state)<br/>2) No real guard (el.style.setProperty)<br/>3) Typeless (or by js CSS.registerProperty but WHY JS)   </p> </article>

CSS Code

@import url('https://fonts.googleapis.com/css?family=Wire+One'); @import url('https://fonts.googleapis.com/css?family=Inconsolata'); body {   display:grid;   place-content:center;   perspective:500px;   min-height:100vh; }  p.tokenize {         font:1em Inconsolata;   line-height:var(--lh);   width:calc(var(--COL) * 1ch);   max-height:calc(var(--lh) * var(--ROW));   hyphens:auto;    overflow:hidden;    clip-path:polygon(0 0, 100% 0,      100% calc((var(--line) - 1) * var(--lh)),     calc(var(--ch)*1ch) calc((var(--line) - 1) * var(--lh)),     calc(var(--ch)*1ch) calc(var(--line) * var(--lh)),     0 calc(var(--line) * var(--lh))   ); }    article {   margin-top:0.5em;   color:hsl(0,0%,50%); }  b {   border:1px solid black;   box-decoration-break:clone; }  h1 {   font:2em "wire one"; }  h2 {   font:1.4em "wire one"; }

JavaScript Snippet

for (const elm of document.querySelectorAll("p.tokenize")) {   // parse "css input"   // type casting is not needed if using CSS TYPED OM   const sty = getComputedStyle(elm);   const ROW = +sty.getPropertyValue("--ROW");   const COL = +sty.getPropertyValue("--COL");   let row = 1;   let col = 1;      (function f() {     elm.style.setProperty("--ch", col);     elm.style.setProperty("--line", row);     if (++col > COL) {       col = 1;       if(++row > ROW)         return     }     setTimeout(f, 16);   }()); }

Preview

Show Animated sentence line by line using JS and CSS Preview

Tags: animatedanimationanimation effectsbyCSSCSS TEXT EFFECTSeffecteffectshtmljslinesentenceShowtexttext effects
Previous Post

Material Design Components code and examples

Next Post

Really clever CSS napkin animation waves effects

Related Stories

CSS Shapes Forest Collection Spring Summer 2020
CSS Code Demos

CSS Shapes Forest Collection Spring Summer 2020

October 11, 2020
CSS Button Concept for Remove and Success
CSS Code Demos

CSS Button Concept for Remove and Success

August 21, 2019
Three Pure different CSS Button effects
CSS Code Demos

Three Pure different CSS Button effects

September 25, 2019
Easy customizable simple CSS buttons
CSS Code Demos

Easy customizable simple CSS buttons

September 8, 2019
Rounded CSS buttons with mouseover effect
CSS Code Demos

Rounded CSS buttons with mouseover effect

September 8, 2019
Collection of CSS3 animated buttons to spice up your site
CSS Code Demos

Collection of CSS3 animated buttons to spice up your site

September 8, 2019
CSS buttons using unicode symbols
CSS Code Demos

CSS buttons using unicode symbols

September 20, 2019
CSS Letter Bouncing Animation Text effect
CSS Code Demos

CSS Letter Bouncing Animation Text effect

September 19, 2019

Discussion about this post

Follow Us

Popular Posts

100 Creative CSS Cards

44 Free Multi step HTML forms

13 Free HTML & CSS Dashboard Template Designs

49 CSS Tables

20 HTML & CSS pricing tables

14 Best CSS Dark Mode

11 CSS Shopping Cart UI/UX

42 Cool CSS Avatars For Better UI

55 Useful handpicked CSS Buttons with examples and demos

89 Best CSS Toggle Switches

w3tweaks

We bring you the best frontend collections that will fix perfect for news, magazine, personal blog, etc. Check our landing page for details.

  • Effects
    • Scroll Effects
    • Text Effects
    • Shadow
  • Essentials
    • Arrows
    • Buttons
    • Background Patterns
    • Border Examples
    • Cards
    • Color Palettes
    • Dividers
    • Link styles
    • Loaders
    • Modal Windows
    • Notifications
    • Progress bar
    • Quote styles
    • Spinner
    • Tooltips
  • Media
    • Calendars
    • Carousels
    • Clocks
    • Gallery
    • Music Players
    • Sliders
    • Slideshows
    • Tables
    • Thumbnails
  • Navigation
  • Inputs
    • Range Sliders
    • Checkboxes
    • Toggle Switches
  • Script
    • Angularjs
    • Backbone.js
    • bootstrap
    • jQuery
    • ReactJs
    • JavaScript
    • Syntax Highlighters
    • tryit editor
    • PHP
  • API’s
    • Facebook
    • Google
    • Indeed
    • Twitter
    • YouTube
  • Tools