入門編:レシピサイト/トップページ

レシピサイト:トップページ

code-step.com


Recipe Diary
日々の料理レシピをまとめています。
和食や洋食、中華、お菓子までいろいろな料理レシピをアップしていますので、
みなさんの献立にお役立てくださいね!

レシピ一覧を見る
Instagram
Twitter
Facebook
© 2022 Recipe Diary
HTML記述例
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>【コーディング練習】レシピサイト/トップページ</title>
<meta name="description" content="画像のトリミングがテーマの課題">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- .main-content -->
<main class="main-content">
  <div class="mainvisual">
    <img src="img/mainvisual.jpg" alt="料理レシピサイトイメージ">
  </div><!-- /.mainvisual -->
  <section class="catchcopy">
    <h1>Recipe Diary</h1>
    <p>日々の料理レシピをまとめています。<br>
      和食や洋食、中華、お菓子までいろいろな料理レシピをアップしていますので、<br>
      みなさんの献立にお役立てくださいね!</p>
  </section>
  <ul class="recipe__example">
    <li><img src="img/recipe1.jpg" alt=""></li>
    <li><img src="img/recipe2.jpg" alt=""></li>
    <li><img src="img/recipe3.jpg" alt=""></li>
  </ul>
  <p class="list__display"><a href="#">レシピ一覧を見る</a></p>
</main>
<!-- /.main-content -->

<!-- .footer -->
<footer class="footer">
  <div class="footer__nav">
    <ul>
      <li><a href="#">Instagram</a></li>
      <li><a href="#">Twitter</a></li>
      <li><a href="#">Facebook</a></li>
    </ul>
  </div>
 <p><small>© 2021 Recipe Diary</small></p>
</footer>
<!-- /.footer -->
</body>
</html>
CSS記述例

Grid Layoutの場合

@charset "UTF-8";

/* -------------------------------------
  reset
------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
ul, li {
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  max-width: 100%;
  vertical-align: bottom;
}


/* -------------------------------------
  body
------------------------------------- */
body {
  color: #333;
  font-size: 16px;
  font-family: 
    "Helvetica Neue",
    Arial,
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    Meiryo,
    sans-serif;
  line-height: 1.0;
}


/* -------------------------------------
  main
------------------------------------- */
.mainvisual img {
  width: 100%;
  height: 100vh;
  object-fit: cover;
  object-position: center top;
}
.catchcopy {
  padding: 86px 0 80px;
  text-align: center;
}
.catchcopy h1 {
  margin-bottom: 20px;
  font-size: 2em;
}
.catchcopy p {
  width: 90%;
  margin: 0 auto;
  line-height: 1.6;
}
.recipe__example {
  margin-bottom: 60px;
}
.recipe__example img {
  width: 100%;
  height: 500px;
  object-fit: cover;
}
.list__display {
  text-align: center;
}
.list__display a {
  display: inline-block;
  margin-bottom: 100px;
  padding: 22px 60px;
  font-size: .875em;
  border: 1px solid #333;
}

@media screen and (min-width: 768px) {

  .recipe__example {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

}


/* -------------------------------------
  footer
------------------------------------- */
.footer {
  padding-bottom: 20px;
  text-align: center;
}
  .footer__nav ul {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    font-size: .78em;
  }
  .footer__nav a {
    text-decoration: underline;
  }
  .footer small {
    font-size: .78em;
  }

Flexbox Layoutの場合

  @media screen and (min-width: 768px) {

    .recipe__example {
      display: flex;
    }
    .recipe__example li {
      width: calc(100% / 3);
    } 

  }