Splitchar is a easy-to-use jQuery plugin that makes it possible to style half a character vertically or horizontally using CSS before/after pseudo-elements.
half color text css, how to change color of half text in html, jquery ui slider styling
Make sure you add the desired style after split char, which are: (horizontal, horizontal-tri, vertical, vertical-tri)
A Word & Character Counter App Developed with jQuery
How to make use of it:
1. Import the jQuery library and jQuery Splitchar.js script into your document.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="js/splitchar.js"></script>
2. Coding.
<!-- Horizontal - 2 Colors --> <h1 class="demo horizontal">jQuery Splitchar.js Demos</h1> <!-- Horizontal - 3 Colors --> <h2 class="demo horizontal-tri">Horizontal 3-color Demo</h2> <!-- Vertical - 2 Colors --> <h2 class="demo vertical">Vertical Demo</h2> <!-- Vertical - 3 Colors --> <h2 class="demo vertical-tri">Vertical 3-color Demo</h2>
3. Apply the following CSS styles to the half-character.
.horizontal { position: relative; display: inline-block; font-size: 64px; overflow: hidden; white-space: pre; color: transparent; } .horizontal:before { display: block; z-index: 1; position: absolute; top: 0; width: 50%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #ecf0f1; } .horizontal:after { display: block; direction: rtl; position: absolute; z-index: 2; top: 0; left: 50%; width: 50%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #bdc3c7; } .horizontal-tri { position: relative; display: inline-block; font-size: 64px; overflow: hidden; white-space: pre; color: #bdc3c7; } .horizontal-tri:before { display: block; z-index: 1; position: absolute; top: 0; width: 33%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #ecf0f1; } .horizontal-tri:after { display: block; direction: rtl; position: absolute; z-index: 2; top: 0; left: 68%; width: 33%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #aaafb2; } .vertical { position: relative; display: inline-block; font-size: 64px; overflow: hidden; white-space: pre; color: transparent; } .vertical:before { display: block; z-index: 2; position: absolute; top: 0; height: 50%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #ecf0f1; } .vertical:after { display: block; direction: rtl; position: absolute; z-index: 1; top: 0; height: 100%; left: 0; content: attr(data-content); overflow: hidden; pointer-events: none; color: #bdc3c7; } .vertical-tri { position: relative; display: inline-block; font-size: 64px; overflow: hidden; white-space: pre; color: #ecf0f1; } .vertical-tri:before { display: block; z-index: 2; position: absolute; top: 0; height: 33%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #bdc3c7; } .vertical-tri:after { display: block; direction: rtl; position: absolute; z-index: 1; top: 0; height: 66%; left: 0; content: attr(data-content); overflow: hidden; pointer-events: none; color: #d2d8d9; }
4. Call the function to enable the plugin.
$(".demo").splitchar();
Style Half of A Character Using jQuery, Splitchar.js Plugin/Github
See Demo And Download
Official Website(razvanbalosin): Click Here
This superior jQuery/javascript plugin is developed by razvanbalosin. For extra Advanced Usages, please go to the official website.