Having trouble getting help?
Contact Support
Contact Support
Customize the card image title position in EJ2 JavaScript Card control
11 May 20234 minutes to read
Card Image titles are placed as always Bottom-Left Corner only, You can manually customize to placing titles anywhere over the image by adding styles.
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 Card Component</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link rel="shortcut icon" href="resources/favicon.ico">
<link href="//cdn.syncfusion.com/ej2/21.2.3/material.css" rel="stylesheet">
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div>
<div id="container">
<!--element which is going to render the Card-->
<div class="e-card">
<div class="e-card-image">
<div class="e-card-title">Node.js</div>
</div>
<div class="e-card-content">
Node.js is a wildly popular platform for writing web applications that has revolutionized web development in many ways, enjoying
support across the open source community as well as industry.
</div>
</div>
</div>
</div>
<div style="Margin: 5px 0;width:300px">
<select id="title_position">
<option value="bottom-left">BottomLeft</option>
<option value="top-left">TopLeft</option>
<option value="top-right">TopRight</option>
<option value="bottom-right">BottomRight</option>
</select>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
// initialize DropDownList component
let dropDownListObject = new ej.dropdowns.DropDownList({
placeholder:"Select Position",
change: changed,
});
// render initialized DropDownList
dropDownListObject.appendTo('#title_position');
function changed(e) {
var cardEle = document.querySelector('.e-card');
var titleEle = cardEle.querySelector('.e-card-image .e-card-title');
titleEle.className = ''
titleEle.classList.add('e-card-title');
titleEle.classList.add('e-card-'+ e.value);
}