[js] Separate long sentence

Size
2,135 Kb
Views
80,960

How do I make an [js] separate long sentence?

What is a [js] separate long sentence? How do you make a [js] separate long sentence? This script and codes were developed by Christophe Béghin on 03 July 2022, Sunday.

[js] Separate long sentence Previews

[js] Separate long sentence - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>[js] Separate long sentence</title> <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="quote">
<h1>Design is not just what it looks like and feels like. Design is how it works.</h1>
<p class="author">— Steve Jobs</p>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://raw.github.com/davatron5000/Lettering.js/master/jquery.lettering.js'></script> <script src="js/index.js"></script>
</body>
</html>

[js] Separate long sentence - Script Codes CSS Codes

body { font-family: 'Montserrat', Arial;
}
h1 { font-size: 28px; margin-bottom: 5px;
}
.quote { background: #eee; width: 600px; padding: 20px; margin: 70px auto;
}
.author { font-style: italic; color: #888;
}
.red,
.black { display: block; color: #DD1100;
}
.black { color: #333;
}

[js] Separate long sentence - Script Codes JS Codes

var str = $('h1').text();
var nb = $('h1').text().length;
var line1 = Math.round(nb/2);
var line2 = nb - line1;
var str1 = str.substring(0, line1);
var str2 = str.substring(line1, line1+line2);
var str1space = line1-str1.lastIndexOf(" ");
var str2space = str2.indexOf(" ")+1;
if(str1space <= str2space) { str1 = str.substring(0, str1.lastIndexOf(" "));
} else { str1 = str.substring(0, str1.length + str2.indexOf(" "));
}
str2 = str.substring(str1.length+1,nb);
str = str.replace(str1, '<span class="red">' + str1 + '</span>', 'i');
str = str.replace(str2, '<span class="black">' + str2 + '</span>', 'i');
$('h1').html(str);
[js] Separate long sentence - Script Codes
[js] Separate long sentence - Script Codes
Home Page Home
Developer Christophe Béghin
Username CBeghin
Uploaded July 03, 2022
Rating 3
Size 2,135 Kb
Views 80,960
Do you need developer help for [js] Separate long sentence?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Christophe Béghin (CBeghin) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!