Képek és Tailwind
This commit is contained in:
1 parent
15ced67b41
commit
464230982d
3 files changed
+74
-5
No files matched your search
@@ -0,0 +1,27 @@
|
||||
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');
|
||||
|
||||
fetch('https://jsonplaceholder.typicode.com/photos')
|
||||
.then(res=>res.json())
|
||||
.then(kepek=>{
|
||||
kepek.forEach(kep => {
|
||||
let kepKontener=document.createElement('div');
|
||||
kepKontener.setAttribute('class','flex flex-col items-center justify-center bg-sky-400 m-2 p-2 rounded-xl w-96');
|
||||
let title=document.createElement('p');
|
||||
title.setAttribute('class','text-2xl text-center font-bold text-sky-600');
|
||||
title.textContent=kep.title;
|
||||
|
||||
let image=document.createElement('img');
|
||||
image.setAttribute('class','rounded-xl');
|
||||
image.src=kep.url;
|
||||
kepKontener.appendChild(image);
|
||||
kepKontener.appendChild(title);
|
||||
kontener.appendChild(kepKontener);
|
||||
});
|
||||
|
||||
})
|
||||
.catch(err=>alert(err));
|
||||
|
||||
root.appendChild(kontener);
|
||||
Reference in new issue
Block a user