Search results

Customize the card image title position

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.

Source
Preview
index.js
index.html
index.css
// initialize DropDownList component
let dropDownListObject = new ej.dropdowns.DropDownList({
    placeholder:"Select Position",
    change: changed,
});

// render initialized DropDownList
dropDownListObject.appendTo('#title_position');

function changed(e) {
    let cardEle = document.querySelector('.e-card');
    let titleEle = cardEle.querySelector('.e-card-image .e-card-title');
    titleEle.className = ''
    titleEle.classList.add('e-card-title');
    titleEle.classList.add(e.value.toLowerCase());
}
<!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/material.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet">
    
    
<script src="//cdn.syncfusion.com/ej2/dist/ej2.min.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>
.e-card-image {
    background: url('./sample.jpg');
    height: 164px;
}

.e-card {
    width: 200px;
    margin: auto;
}