<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
  <link href="style.css" rel="stylesheet" />
  <link href="https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap" rel="stylesheet">
</head>

<body>
  <div id="root"></div>
  <script src="scripts.js"></script>
</body>
body {
  text-align: center;
  color: #355070;
  font-family: "Roboto", sans-serif;
  background-color: #eaac8b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23e56b6f' fill-opacity='0.26'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

h1 {
  font-family: "Permanent Marker", cursive;
  font-size: 4em;
  color: #b56576;
}

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  flex-direction: row-reverse;
}

.name {
  font-weight: bold;
}
.location {
  font-size: 0.8em;
  color: #6d597a;
}
.card {
  display: flex;
  justify-content: space-evenly;
  padding: 1em;
  margin: 1rem;
  border-radius: 5px;
  background: #fff;
  width: 200px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
}

.greeting {
  animation: slideIn 2s;
}

@keyframes slideIn {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(100px);
  }
  100% {
    transform: translateX(0);
  }
}

.card:hover {
  transform: rotate(-5deg);
}

.card img {
  margin-left: 1em;
  border-radius: 50%;
  max-width: 50px;
}
const app = document.getElementById("root");

const header = document.createElement("h1");
header.textContent = "Friends!";
header.setAttribute("class", "greeting");
app.append(header);

const container = document.createElement("div");
container.setAttribute("class", "container");
app.append(container);

const people = fetch("https://randomuser.me/api/?results=12")
  .then((response) => {
    return response.json();
  })
  .then((data) => {
    data.results.forEach((person) => {
      const card = document.createElement("div");
      card.setAttribute("class", "card");

      const { name, location } = person;

      const p = document.createElement("p");

      p.textContent = `${name.first}`;

      p.setAttribute("class", "name");
      const p2 = document.createElement("p");
      p2.textContent = `🏡 ${location.state}`;

      p2.setAttribute("class", "location");
      const img = document.createElement("img");
      img.src = person.picture.medium;

      const textContainer = document.createElement("div");
      container.append(card);
      card.append(textContainer);
      textContainer.append(p);
      textContainer.append(p2);

      const imgContainer = document.createElement("div");
      card.append(imgContainer);
      imgContainer.append(img);
    });
  })
  .catch((err) => console.log(err.toString()));

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.