[js] Separate long sentence
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 - 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);
Developer | Christophe Béghin |
Username | CBeghin |
Uploaded | July 03, 2022 |
Rating | 3 |
Size | 2,135 Kb |
Views | 80,960 |
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!
Name | Size |
Audio player | 2,971 Kb |
Flipping thumbnails | 3,742 Kb |
Animated search Form | 3,928 Kb |
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!
Name | Username | Size |
A Pen by Alex Bergin | Abergin | 3,347 Kb |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Fading gradient button | Insprd | 1,713 Kb |
CSS only simple parallax scroll | Stanssongs | 3,708 Kb |
Social.svg.min | Larsenwork | 13,849 Kb |
Greyscale image with filter in CSS3 | NickyCDK | 1,562 Kb |
Speech bubbles | Something | 1,547 Kb |
Cloudy Spiral CSS animation | Hakimel | 6,587 Kb |
HTML5 Breakout | Jaysalvat | 4,873 Kb |
Coming Soon | MariamMassadeh | 1,680 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!