-
Notifications
You must be signed in to change notification settings - Fork 0
/
Level 1 - question 2.html
70 lines (43 loc) · 1.21 KB
/
Level 1 - question 2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Question 2</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<style>
.container {
display: flex;
flex-direction: column;
}
.card {
width: 300px;
height: 250px;
background-color: #ecf0f1;
float: right;
margin: 10px;
}
</style>
</head>
<body onload="cards()">
<div class="container">
<div id="display"></div>
</div>
<script>
function cards(){
fetch('https://jsonplaceholder.typicode.com/todos')
.then((res) => res.json())
.then((data) => {
let display = '<br>';
data.forEach(function(post){
display += `
<div class="card card-body mb-3">
<h2>${post.title}</h2>
</div>
`;
});
document.getElementById('display').innerHTML = display;
})
}
</script>
</body>
</html>