JSFiddle - React, Tailwind, and code Playground
by Andres Abadia
HTML
<div class="tile-image"></div>
CSS
.tile-image img {
width: 432px;
height: 192px;
object-fit: cover;
border-radius: 4px;
}
.tile-image img{
/*width: 100%;*/
}
JavaScript
data = {
"tiles" : [
{
"img" : "https://images.pexels.com/photos/1640776/pexels-photo-1640776.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
},
{
"img" : "https://images.pexels.com/photos/1640776/pexels-photo-1640776.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
}
]
};
data.tiles.forEach((item) => {
let img = new Image();
img.src = item.img;
tile = document.getElementsByClassName("tile-image")[0];
tile.appendChild(img);
});