Getting Started with EJ2 JavaScript Avatar
24 Nov 20262 minutes to read
The Essential® JS 2 for JavaScript (global script) is an ES5 formatted pure JavaScript framework that can be directly used in latest web browsers.
Setup for local environment
Refer to the following steps to set up your local environment.
Step 1: Create a root folder named my-app for your application.
Step 2: Create a my-app/resources folder to store local scripts and styles files.
Step 3: Open Visual Studio Code and create my-app/index.js and my-app/index.html files to initialize the Essential® JS 2 Avatar control.
Control Initialization
The Essential® JS 2 JavaScript controls can be initialized by using below css styles and scripts
Add Syncfusion® Avatar CSS Styles and Scripts
Include the following CSS and JavaScript files from CDN in the <head> section of the index.html file.
Styles(CSS):
https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/avatar/index.cssAdding Avatar component to the application
Add the span element and initiate the Essential® JS 2 Avatar component in the index.html by using the following code.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Essential JS 2</title>
<link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/avatar/index.css" rel="stylesheet" />
</head>
<body>
<!-- Add the HTML <span> element -->
<div id='element'>
<span class="e-avatar e-avatar-xlarge"></span>
<span class="e-avatar e-avatar-large"></span>
<span class="e-avatar"></span>
<span class="e-avatar e-avatar-small"></span>
<span class="e-avatar e-avatar-xsmall"></span>
</div>
<style>
#element {
display: block;
width: 300px;
margin: 130px auto;
border-radius: 3px;
justify-content: center;
}
.e-avatar {
background-image: url(https://ej2.syncfusion.com/demos/src/avatar/images/pic01.png);
}
</style>
</body>
</html>