Card image in Angular Card component

27 Aug 20255 minutes to read

Images

The Card component supports including images within its elements. You can add an image as a direct element anywhere inside the card root by adding the e-card-image class to a div element. Using this class, you can write CSS styles to load images into that element.

By default, card images occupy the full width of their parent element.

    <div class = "e-card">
        <div class="e-card-image">
        </div>
    </div>

Title

Card images support including a title or caption for the image. By default, the title is placed over the image in the left-bottom position with an overlay effect.

    <div class = "e-card">
        <div class="e-card-image">
            <div class="e-card-title"></div>
        </div>
    </div>
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'



import { Component, ViewChild } from '@angular/core';

@Component({
imports: [
        
    ],


standalone: true,
    selector: 'app-container',
    template: `
        <div class="e-card">
            <div class="e-card-image">
                <div class="e-card-title">JavaScript </div>
            </div>
            <div class="e-card-content"> JavaScript Succinctly was written to give readers an accurate, concise examination of JavaScript objects and their supporting nuances, such as complex values, primitive values, scope, inheritance, the head object, and more. </div>
        </div>
        `
})

export class AppComponent {
    @ViewChild('element') element: any;

    ngAfterViewInit() {
    }
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Divider

Dividers are used to separate elements inside the card. You can add a divider inside the card elements to create visual separation between different sections.

  • Place a div element with the e-card-separator class inside the card element to add a divider.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'



import { Component, ViewChild } from '@angular/core';

@Component({
imports: [
        
    ],


standalone: true,
    selector: 'app-container',
    template: `
        <div tabindex="0" class="e-card" id="basic">
            <div class="e-card-title">Explore Cities</div>
            <div class="e-card-separator"></div>
            <div class="e-card-content">
                Sydney is a city on the east coast of Australia. Sydney is the capital city of New South Wales. About four million people
                live in Sydney which makes it the biggest city in Oceania.
            </div>
            <div class="e-card-separator"></div>
            <div class="e-card-content">
                New York City has been described as the cultural, financial, and media capital of the world, and exerts a significant impact
                upon commerce and etc.,
            </div>
            <div class="e-card-separator"></div>
            <div class="e-card-content">
                Malaysia is one of the Southeast Asian countries, on a peninsula of the Asian continent, to a certain extent; it can be recognized
                as part of the Asian continent.
            </div>
        </div>
        `
})

export class AppComponent {
    @ViewChild('element') element: any;

}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

See Also