let root=document.getElementById('root'); let kontener=document.createElement('div'); //kontener.setAttribute('class','flex flex-row flex-wrap items-center justify-center bg-sky-200'); kontener.setAttribute('class','grid lg:grid-cols-4 md:grid-cols-2 sm:grid-cols-1 justify-items-center bg-sky-200'); fetch('https://jsonplaceholder.typicode.com/photos') .then(res=>res.json()) .then(adat=>{ //console.log(adat) adat.forEach(kep => { let kepkontener=document.createElement('div'); kepkontener.setAttribute('class','flex flex-col items-center justify-center rounded-xl w-96 bg-sky-400 m-2 p-2'); let title=document.createElement('p'); title.setAttribute('class','text-2xl text-center text-sky-800'); title.textContent=kep.title; let image=document.createElement('img'); image.setAttribute('class','rounded-xl w-96') image.src=kep.url; kepkontener.appendChild(image); kepkontener.appendChild(title); kontener.appendChild(kepkontener); }); }) .catch(err=>alert(err)); root.appendChild(kontener);