Skip to content

A lightweight jQuery plugin that sets an element's text to either black or white automatically, depending on the background color to give the best contrast. If an element does not have a background, the parent element's background is used and so on until a background is found.

License

Notifications You must be signed in to change notification settings

TetrisSmalls/AutoTextColor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

AutoTextColor

A lightweight jQuery plugin that sets an element's text to either black or white automatically, depending on the background color to give the best contrast. If an element does not have a background, the parent element's background is used and so on until a background is found.

Demo / Examples

AutoTextColor Demo / Examples

Usage

<div class="card" style="background: #fe626d;">
  <h2>Lorem Ipsum</h2>
  <p>Sed dapibus nunc ac blandit porta.</p>
</div>
$(document).ready(function(){
  $('div.card').autotextcolor();
});

About

A lightweight jQuery plugin that sets an element's text to either black or white automatically, depending on the background color to give the best contrast. If an element does not have a background, the parent element's background is used and so on until a background is found.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published