jQuery Plugin To Create Text Avatars From User Names - Avatarme
File Size: | 6.5 KB |
---|---|
Views Total: | 8567 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |

Avatarme is a super tiny jQuery plugin which allows you to create a circular text avatar by picking the first letter from each word of a phrase (user name).
How to use it:
1. Load the latest jQuery library and the jQuery Avatarme plugin at the end of the document.
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="src/jquery.avatarme-1.0.min.js"></script>
2. Wrap an user name into an Html element.
<span class="user-name">jQuery Script Net</span>
3. Initialize the plugin to generate a text avatar from the user name.
jQuery(function($){ var $userName = $('.user-name'); if ($userName.length) { $userName.avatarMe({ avatarClass: 'avatar-me', max: 3 // maximum letters displayed in the avartar }); } });
4. Style the text avatar whatever you like in the CSS.
.avatar-me-wrapper { min-height: 48px; overflow: hidden; padding-left: 58px; position: relative; } .avatar-me { background-color: #e74c3c; color: #fff; display: block; height: 48px; left: 0; overflow: hidden; padding: 0 10px; position: absolute; text-align: center; text-overflow: ellipsis; text-transform: uppercase; top: 0; white-space: nowrap; width: 48px; -webkit-border-radius: 50%; -moz-border-radius: 50%; border-radius: 50%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .avatar-me { line-height: 48px; font-size: 18px; font-weight: 300; } /* For mobile */ @media screen and (min-width: 481px) { .avatar-me-wrapper { min-height: 64px; padding-left: 79px; } .avatar-me, .user-name { line-height: 64px; } .avatar-me { height: 64px; width: 64px; } .avatar-me { font-size: 24px; } }
Change log:
2014-10-08
- update plugin options
This awesome jQuery plugin is developed by lbphuc. For more Advanced Usages, please check the demo page or visit the official website.