<div class="bentou">
  <p class="bentou_ttl">毎日弁当の内容物に困っているエンジニアへ</p>
  <ul class="content">
    <li class="item">
      <p id="p1">?</p>
    </li>
    <li class="item">
      <p id="p2">?</p>
    </li>
    <li class="item">
      <p id="p3">?</p>
    </li>
    <li class="item">
      <p id="p4">?</p>
    </li>
  </ul>
  <button class="btn" id="menubtn" type="button">
    <span>What should in my Bentou?
    </span>
  </button>
</div>
p {
  margin: 0;
}

.loading {
    width: 100%;
    height: 100vh;
    display: grid;
    place-content: center;
    display: none
}

.bentou {
    width: 100%;
    height: 100vh
}

.bentou .bentou_ttl {
    width: -moz-fit-content;
    width: fit-content;
    margin-inline:auto;
    padding-top: 252px;
    font-size: 50px
}

.content {
    margin-top: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 38px
}

.content .item {
    width: 272px;
    height: 305px;
    background-color: #d9d9d9;
    border-radius: 10px;
    box-shadow: -5px -5px -5px #f3f1f1;
    display: flex;
    justify-content: center;
    align-items: center
}

.content .item p {
    font-weight: 500;
    font-size: 1.5rem;
    color: #fff
}

.btn {
    width: 396px;
    height: 68px;
    margin-inline:auto;margin-top: 123px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #d9d9d9;
    box-shadow: 5px 5px 5px #f3f1f1;
    border-radius: 10px
}
.btn span {
  font-size: 18px;
}
function getRandom(length){
  return Math.floor(Math.random() * length);
}

document.getElementById("menubtn").addEventListener("click", event=>{
  console.log("cilck!!!");
  
  const m1 = ["キュウリ","キャベツ","なす","トマト","レタス","小松菜"];
  const m2 = ["鶏もも","鶏むね","牛肉","ラム","豚肉"];
  const m3 = ["バナナ","リンゴ","ブドウ","アボカド","梨"];
  const m4 = ["キムチ","梅干し","浅漬","ザーサイ"];

  const s1 = m1[getRandom(m1.length)];
  const s2 = m2[getRandom(m2.length)];
  const s3 = m3[getRandom(m3.length)];
  const s4 = m4[getRandom(m4.length)];

  document.getElementById("p1").textContent = s1;
  document.getElementById("p2").textContent = s2;
  document.getElementById("p3").textContent = s3;
  document.getElementById("p4").textContent = s4;
})

Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.