I want to display card views in my web page. The card view should have a background image, and below that there should be the Card title, and again below that there should be some short texts.
Here's how I have tried the code,
<h1>ViewAllVehicles</h1>
<div class="card-columns">
@foreach (var item in Model)
{
<div class="card">
<div class="card-img" style="background-image: url('@("~/VehicleImages/"+item.vehicleImageName)')"></div>
<div class="card-body">
<h5 class="card-title">@item.vehicleType</h5>
</div>
@item.vehicleAvailability
@item.plateNumber
</div>
}
</div>
Currently this is the result I get,
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/O6P3L.jpg
It's not exactly clear which solution you want so I will provide both from the bootstrap docs. The first one is for a background image with an overlay:
Or second option: image with text below it:
As you can see, your first problem is that you are missing an img tag for you background image. Now that I re-read your question, my guess is that you want option 2.