Web白描

Webデザインの勉強 - 演習

課題12 IKECODE

課題12 IKECODE 完成例

記述ポイント
  • 横並びを縦並びに変更するために、メディアクエリ内で「display: block;」を指定する
  • 文字を読みやすくサイズ変更
  • 画像の並びをスマートフォンに最適化する

style.css

@charset "UTF-8";

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


/* ----------------------------------------
  body
---------------------------------------- */
body {
  background-color: #fff;
  color: #333;
  font-size: 16px;
  font-family:
    "Josefin Sans", "Noto Sans JP", sans-serif;
  line-height: 1.0;
}


/* ----------------------------------------
  layout(共通)
---------------------------------------- */
.container {
  width: min(92%, 960px);
  margin: 0 auto;
}
.sec_block {
  padding: 80px 0;
}
h2 {
  margin-bottom: 40px;
  font-size: 32px;
  font-weight: 600;
  text-align: center;
}


/* ----------------------------------------
  header
---------------------------------------- */
.header > .container {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 40px 0 30px;
}
  h1 {
    width: fit-content;
    margin-right: auto;
    font-weight: 600;
    font-size: 38px;
  }

@media screen and (max-width: 767px) {
  .header > .container {
    display: block;
    padding: 20px 0;
    text-align: center;
  }
  h1 {
    width: fit-content;
    margin: 0 auto;
    font-weight: 600;
    font-size: 38px;
  }
}


/* ----------------------------------------
  nav
---------------------------------------- */
.gnav > ul {
  display: flex;
  justify-content: center;
  align-items: center;
}
  .gnav li {
    font-size: 16px;
  }
  .gnav li a {
    display: block;
    padding: 20px 20px 16px;
    transition: .3s;
  }
    .gnav li:last-child a {
      background-color: #000;
      color: #fff;
    }
    .gnav li a:hover {
      opacity: 0.5;
    }


/* ----------------------------------------
  main_visual
---------------------------------------- */
.main_visual {
  margin-bottom: 80px;
}
  .main_visual img {
    width: 100%;
    height: 600px;
    object-fit: cover;
  }

@media screen and (max-width: 767px) {
  .main_visual {
    margin-bottom: 30px;
  }
  .sec_block {
    padding: 20px 0;
  }
}


/* ----------------------------------------
  about
---------------------------------------- */
#about ul {
  margin-bottom: 16px;
  padding-left: 5.0rem;
  list-style: disc;
  font-size: 18px;
}
  #about ul li, #about p {
    font-size: 18px;
    line-height: 1.8;
  }

@media screen and (max-width: 767px) {
  #about ul {
    padding-left: 2.0rem;
  }
  #about ul li, #about p {
    font-size: 1.05rem;
    line-height: 1.6;
  }
}


/* ----------------------------------------
  works
---------------------------------------- */
#works ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
  #works ul li {
    width: 100%;
  }

@media screen and (max-width: 767px) {
  #works ul {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
}


/* ----------------------------------------
  news
---------------------------------------- */
#news dl {
  display: grid;
  grid-template-columns: 8.0rem auto;
  border-top: 1px solid #aaa;
}
  #news dt {
    padding-top: 6px;
    padding-left: 1.0rem;
    border-bottom: 1px solid #aaa;
    line-height: 2.4;
    font-weight: 700;
  }
  #news dd {
    padding-top: 6px;
    border-bottom: 1px solid #aaa;
    line-height: 2.4;
  }

@media screen and (max-width: 767px) {
  #news dl {
    display: block;
  }
    #news dt {
      padding-top: 6px;
      padding-left: 1.0rem;
      border-bottom: 0;
      line-height: 1.4;
    }
    #news dd {
      margin-bottom: 10px;
      padding: 6px 0 6px 1.0rem;
      border-bottom: 1px solid #aaa;
      line-height: 1.4;
    }
}


/* ----------------------------------------
  contact
---------------------------------------- */
#contact p {
  text-align: center;
  margin-bottom: 20px;
}
#contact dl {
  display: grid;
  grid-template-columns: 10rem auto;
  margin-bottom: 20px;
  position: relative;
}
#contact dl::before {
  content: '※は必須項目';
  position: absolute;
  top: -30px;
  left: 0;
  color: #f00;
  font-size: 12px;
}
  #contact dt {
    position: relative;
    padding-left: 1em;
  }
  #contact dt::before {
    content: '※';
    position: absolute;
    top: 0;
    left: 0;
    color: #f00;
    font-size: 12px;
  }
  #contact dd {
    margin-bottom: 10px;
  }
    #contact dd input,
    #contact dd textarea {
      width: 100%;
      border: solid 1px #aaa;
      padding: 10px;
    }
    #contact dd textarea {
      height: 160px;
    }
  #contact .button {
    text-align: center;
  }
    #contact .button input {
      border: solid 1px #24292e;
      width: 200px;
      background-color: #24292e;
      color: #fff;
      padding: 15px 0;
      transition: .3s;
    }
    #contact .button input:hover {
      background: #fff;
      color: #24292e;
    }

@media screen and (max-width: 767px) {
  #contact p {
    margin-bottom: 40px;
  }
  #contact dl {
    display: block;
  }
  #contact dt {
    margin-bottom: 4px;
  }
}


/* ----------------------------------------
  footer
---------------------------------------- */
.footer {
  padding: 0 0 20px;
}
  .footer p {
    font-size: 14px;
    text-align: center;
  }

index.html

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>IKRCODE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="img/favicon.ico">

<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital,wght@0,100..700;1,100..700&family=Noto+Sans+JP:wght@100..900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- header -->
<header class="header">
  <div class="container">
    <h1 class="site-title"><a href="#">IKECODE</a></h1>
    <nav class="gnav">
      <ul>
        <li><a href="#about">ABOUT</a></li>
        <li><a href="#works">WORKS</a></li>
        <li><a href="#news">NEWS</a></li>
        <li><a href="#contact">CONTACT</a></li>
      </ul>
    </nav>
  </div><!-- /.container -->
</header>
<!-- /header -->

<!-- main -->
<main class="main">
  <div class="main_visual">
    <img src="img/main_pc.webp" alt="">
  </div><!-- /.main_visual -->
  <div class="container">
    <!-- about -->
    <section id="about" class="sec_block">
      <h2>About</h2>
      <ul>
        <li>IKECODE株式会社</li>
        <li>Web制作会社として設立</li>
        <li>Webサイト・アプリ開発を承ります</li>
        <li>メールアドレス:ikecode@sample.com</li>
      </ul>
      <p>
        Webサイト制作やアプリ開発を得意としています。また、新人の育成をしたい企業も募集しております。
      </p>
    </section>
    <!-- works -->
    <section id="works" class="sec_block">
      <h2>Works</h2>
      <ul>
        <li><img src="img/works1.webp" alt="work1"></li>
        <li><img src="img/works2.webp" alt="work2"></li>
        <li><img src="img/works3.webp" alt="work3"></li>
        <li><img src="img/works4.webp" alt="work4"></li>
        <li><img src="img/works5.webp" alt="work5"></li>
        <li><img src="img/works6.webp" alt="work6"></li>
        <li><img src="img/works7.webp" alt="work1"></li>
        <li><img src="img/works8.webp" alt="work2"></li>
        <li><img src="img/works9.webp" alt="work3"></li>
      </ul>
    </section>
    <!-- news -->
    <section id="news" class="sec_block">
      <h2>News</h2>
      <dl>
        <dt>2024/10/23</dt>
        <dd>YouTubeチャンネルを開始しました。【チャンネル登録】よろしくお願いいたします。</dd>
        <dt>2024/8/19</dt>
        <dd>新しい記事の更新をしました。</dd>
        <dt>2024/4/4</dt>
        <dd>新しい記事の更新をしました。</dd>
        <dt>2024/2/17</dt>
        <dd>IKECODEが、Webサイトを公開しました。</dd>
      </dl>
    </section>
    <!-- contact -->
    <section id="contact" class="sec_block">
      <h2 class="sec-title">Contact</h2>
      <p>お問い合わせは以下のフォームから</p>
      <form action="#" method="post">
        <dl>
          <dt><label for="name">お名前</label></dt>
          <dd><input type="text" id="name" required placeholder="田中 景子"></dd>
          <dt><label for="email">メールアドレス</label></dt>
          <dd><input type="email" id="email" required placeholder="tanaka@gmail.com"></dd>
          <dt><label for="content">内容</label></dt>
          <dd><textarea id="content" required placeholder="お問合せ内容をお書きください。"></textarea></dd>
        </dl>
        <div class="button"><input type="submit" value="送信"></div>
      </form>
    </section>
  </div><!-- /.container -->
</main>
<!-- /main -->

<!-- footer -->
<footer class="footer">
  <p><small>&copy; IKECODE</small></p>
</footer>
<!-- /footer -->
</body>
</html>